<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Catalog Views on SQL Server Scripts</title><link>https://www.sqlserver70.com/tags/catalog-views/</link><description>Recent content in Catalog Views on SQL Server Scripts</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>SQLServer70.com</copyright><lastBuildDate>Fri, 19 Jun 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://www.sqlserver70.com/tags/catalog-views/index.xml" rel="self" type="application/rss+xml"/><item><title>System-Versioned (Temporal) Tables in SQL Server</title><link>https://www.sqlserver70.com/post/sql-server-system-versioned-temporal-tables/</link><pubDate>Fri, 19 Jun 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-system-versioned-temporal-tables/</guid><description>
&lt;p&gt;Every &lt;code&gt;UPDATE&lt;/code&gt; and &lt;code&gt;DELETE&lt;/code&gt; on a system-versioned table leaves behind a complete, queryable history of the previous row — automatically, with no triggers and no audit-table plumbing. SQL Server records the period each row version was valid and answers point-in-time questions through a single &lt;code&gt;FOR SYSTEM_TIME&lt;/code&gt; clause. This is the temporal-tables feature, available since SQL Server 2016.&lt;/p&gt;
&lt;script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1012089347386563"
crossorigin="anonymous"&gt;&lt;/script&gt;
&lt;ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-1012089347386563"
data-ad-slot="8593449130"&gt;&lt;/ins&gt;
&lt;script&gt;
(adsbygoogle = window.adsbygoogle || []).push({});
&lt;/script&gt;
&lt;h2 id="purpose-and-overview"&gt;Purpose and Overview&lt;/h2&gt;
&lt;p&gt;A system-versioned temporal table is a user table that keeps a full history of data changes so you can analyze the data as it existed at any point in the past, not just as it is now. The feature is implemented as a pair of tables: the &lt;em&gt;current&lt;/em&gt; table holds the present rows, and a linked &lt;em&gt;history&lt;/em&gt; table stores prior versions. The Database Engine manages the relationship — on every update or delete, it closes the old row in the history table and stamps a new period of validity.&lt;/p&gt;</description></item><item><title>SQL Server Database Schema and Data Dictionary Queries</title><link>https://www.sqlserver70.com/post/sql-server-database-schema-data-dictionary-queries/</link><pubDate>Thu, 18 Jun 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-database-schema-data-dictionary-queries/</guid><description>
&lt;p&gt;Documenting a database starts with a data dictionary: every table, every column, its data type, length, nullability, and default. SQL Server exposes this through the ANSI-standard &lt;code&gt;INFORMATION_SCHEMA&lt;/code&gt; views, which produce a portable schema report that reads almost like English and runs unchanged on other ISO-compliant database engines.&lt;/p&gt;
&lt;script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1012089347386563"
crossorigin="anonymous"&gt;&lt;/script&gt;
&lt;ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-1012089347386563"
data-ad-slot="8593449130"&gt;&lt;/ins&gt;
&lt;script&gt;
(adsbygoogle = window.adsbygoogle || []).push({});
&lt;/script&gt;
&lt;h2 id="purpose-and-overview"&gt;Purpose and Overview&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;INFORMATION_SCHEMA&lt;/code&gt; is a set of views defined by the ISO SQL standard and implemented in a special schema present in every SQL Server database. Their purpose is insulation: they present an internal, system-table-independent view of metadata, so applications keep working even when the underlying system tables change between releases. That portability is the main reason to reach for them — a data-dictionary query written against &lt;code&gt;INFORMATION_SCHEMA&lt;/code&gt; will run on SQL Server, PostgreSQL, MySQL, and other engines that implement the standard.&lt;/p&gt;</description></item><item><title>sp_pkeys and Primary Key Metadata in SQL Server</title><link>https://www.sqlserver70.com/post/sql-server-sp-pkeys-primary-key-metadata/</link><pubDate>Tue, 16 Jun 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-sp-pkeys-primary-key-metadata/</guid><description>
&lt;p&gt;Which columns make up a table's primary key, and in what order are they declared? For a single table, the system stored procedure &lt;code&gt;sp_pkeys&lt;/code&gt; answers in one line; for a database-wide inventory, the catalog views behind it give you full control. This post covers both, from the quick lookup to the complete metadata query.&lt;/p&gt;
&lt;script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1012089347386563"
crossorigin="anonymous"&gt;&lt;/script&gt;
&lt;ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-1012089347386563"
data-ad-slot="8593449130"&gt;&lt;/ins&gt;
&lt;script&gt;
(adsbygoogle = window.adsbygoogle || []).push({});
&lt;/script&gt;
&lt;h2 id="purpose-and-overview"&gt;Purpose and Overview&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;sp_pkeys&lt;/code&gt; returns primary key information for one table in the current database. It is an ODBC-catalog procedure — the T-SQL equivalent of the &lt;code&gt;SQLPrimaryKeys&lt;/code&gt; ODBC function — and its result set is deliberately compact: &lt;code&gt;TABLE_QUALIFIER&lt;/code&gt;, &lt;code&gt;TABLE_OWNER&lt;/code&gt;, &lt;code&gt;TABLE_NAME&lt;/code&gt;, &lt;code&gt;COLUMN_NAME&lt;/code&gt;, &lt;code&gt;KEY_SEQ&lt;/code&gt;, and &lt;code&gt;PK_NAME&lt;/code&gt;. The &lt;code&gt;KEY_SEQ&lt;/code&gt; column is the one that matters most: it gives the sequence number of each column within a multicolumn primary key, so a composite key returns one row per column in declared order.&lt;/p&gt;</description></item><item><title>sysindexes vs sys.indexes: Legacy and Modern Catalog Views</title><link>https://www.sqlserver70.com/post/sql-server-sysindexes-vs-sys-indexes-catalog-views/</link><pubDate>Mon, 15 Jun 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-sysindexes-vs-sys-indexes-catalog-views/</guid><description>
&lt;p&gt;Plenty of SQL Server scripts still in circulation read &lt;code&gt;rowcnt&lt;/code&gt; and &lt;code&gt;dpages&lt;/code&gt; straight out of &lt;code&gt;sysindexes&lt;/code&gt; — a habit inherited from SQL Server 2000, where that table was the canonical place to find row counts and page totals. The object survives only as the &lt;code&gt;sys.sysindexes&lt;/code&gt; compatibility view, is flagged for removal, and returns inaccurate numbers for partitioned tables. This post shows the modern replacement and how to migrate.&lt;/p&gt;
&lt;script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1012089347386563"
crossorigin="anonymous"&gt;&lt;/script&gt;
&lt;ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-1012089347386563"
data-ad-slot="8593449130"&gt;&lt;/ins&gt;
&lt;script&gt;
(adsbygoogle = window.adsbygoogle || []).push({});
&lt;/script&gt;
&lt;h2 id="purpose-and-overview"&gt;Purpose and Overview&lt;/h2&gt;
&lt;p&gt;In SQL Server 2000, &lt;code&gt;sysindexes&lt;/code&gt; was a real system table with one row per index and heap, and DBAs leaned on its &lt;code&gt;rowcnt&lt;/code&gt;, &lt;code&gt;dpages&lt;/code&gt;, &lt;code&gt;reserved&lt;/code&gt;, and &lt;code&gt;used&lt;/code&gt; columns for quick size and row-count reports. SQL Server 2005 rebuilt the metadata layer, and &lt;code&gt;sysindexes&lt;/code&gt; was retained only as &lt;code&gt;sys.sysindexes&lt;/code&gt;, a backward-compatibility view. Microsoft's documentation is explicit: this feature is included for backward compatibility, will be removed in a future version, and should not be used in new development.&lt;/p&gt;</description></item><item><title>SQL Server Catalog Views: sys.tables, sys.indexes, sys.objects</title><link>https://www.sqlserver70.com/post/sql-server-system-catalog-views-sys-tables-indexes-objects/</link><pubDate>Sun, 14 Jun 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-system-catalog-views-sys-tables-indexes-objects/</guid><description>
&lt;p&gt;The &lt;code&gt;sys&lt;/code&gt; catalog views are the supported, forward-compatible way to read SQL Server metadata, and three of them — &lt;code&gt;sys.objects&lt;/code&gt;, &lt;code&gt;sys.tables&lt;/code&gt;, and &lt;code&gt;sys.indexes&lt;/code&gt; — answer most day-to-day questions about what lives in a database. This script joins them into one inventory of every user table, its schema, its row count, and each index defined on it.&lt;/p&gt;
&lt;script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1012089347386563"
crossorigin="anonymous"&gt;&lt;/script&gt;
&lt;ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-1012089347386563"
data-ad-slot="8593449130"&gt;&lt;/ins&gt;
&lt;script&gt;
(adsbygoogle = window.adsbygoogle || []).push({});
&lt;/script&gt;
&lt;h2 id="purpose-and-overview"&gt;Purpose and Overview&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;sys.objects&lt;/code&gt; is the base catalog view: it contains one row for every user-defined, schema-scoped object in a database — tables, views, stored procedures, functions, constraints, triggers, and more — each identified by a unique &lt;code&gt;object_id&lt;/code&gt;. &lt;code&gt;sys.tables&lt;/code&gt; is a &lt;em&gt;derived&lt;/em&gt; view built on top of it. It returns every column &lt;code&gt;sys.objects&lt;/code&gt; returns, plus table-specific columns such as &lt;code&gt;temporal_type&lt;/code&gt; and &lt;code&gt;is_memory_optimized&lt;/code&gt;, but only for rows where the object is a user table. &lt;code&gt;sys.indexes&lt;/code&gt; then carries one row per index or heap of each tabular object, keyed back to the table by &lt;code&gt;object_id&lt;/code&gt;.&lt;/p&gt;</description></item></channel></rss>