<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Database Structure on SQL Server Scripts</title><link>https://www.sqlserver70.com/tags/database-structure/</link><description>Recent content in Database Structure on SQL Server Scripts</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>SQLServer70.com</copyright><lastBuildDate>Sat, 18 Apr 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://www.sqlserver70.com/tags/database-structure/index.xml" rel="self" type="application/rss+xml"/><item><title>SQL Server Foreign Keys Without Indexes Script</title><link>https://www.sqlserver70.com/post/sql-server-foreign-keys-without-indexes-script/</link><pubDate>Sat, 18 Apr 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-foreign-keys-without-indexes-script/</guid><description>
&lt;p&gt;Foreign keys enforce referential integrity, but SQL Server does not automatically create indexes on the referencing (child) columns. An unindexed foreign key column forces a full table scan every time a join or a DELETE on the parent table triggers a referential check. This script identifies all foreign key columns in the current database that have no supporting index, and generates the &lt;code&gt;CREATE INDEX&lt;/code&gt; statements to fix them.&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;When you run a &lt;code&gt;DELETE&lt;/code&gt; on a parent table, SQL Server must verify that no child rows reference the deleted parent. If the child table's foreign key column has no index, SQL Server performs a full table scan on the child table for every deleted parent row. On large tables this can make simple deletes extremely slow and cause blocking on the child table.&lt;/p&gt;</description></item><item><title>SQL Server: Find Tables Without Primary Keys</title><link>https://www.sqlserver70.com/post/sql-server-find-tables-without-primary-keys/</link><pubDate>Thu, 16 Apr 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-find-tables-without-primary-keys/</guid><description>
&lt;p&gt;Tables without primary keys are heap structures with no guaranteed row ordering and no unique row identifier. They cause full table scans in queries that could use seeks, slow down DELETE and UPDATE operations, and are incompatible with SQL Server replication and Change Data Capture. This script finds every user table in the current database that has no primary key defined.&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 primary key enforces uniqueness on a column or set of columns and, by default, creates a clustered index that physically orders the table rows. Without a primary key, SQL Server stores rows in a heap: an unordered structure where updates and deletes must first locate rows through a full scan or a nonclustered index lookup followed by a separate heap RID lookup.&lt;/p&gt;</description></item></channel></rss>