﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by William Talada  / Find botched constraints, idxs, fks / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Wed, 22 May 2013 13:21:47 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Find botched constraints, idxs, fks</title><link>http://www.sqlservercentral.com/Forums/Topic833291-1710-1.aspx</link><description>Here's a quick script to run it against all of your tables. I've still got to figure out your syntax a bit better ;-)DougCREATE PROCEDURE [dbo].[ExamineAllTables]ASBEGIN	SET NOCOUNT ON		DECLARE		@TableCnt		INT,		@CurrentTable	INT,		@Table		SYSNAME			CREATE TABLE #TableListing	(		[IndexListingID]	INT IDENTITY(1,1) PRIMARY KEY CLUSTERED,		[TableName]	SYSNAME COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL	)		INSERT INTO #TableListing( [TableName] )	SELECT [Name]	FROM sys.tables	ORDER BY [Name]	SELECT @TableCnt = @@ROWCOUNT, @CurrentTable = 1		WHILE @CurRentTable &amp;lt;= @TableCnt	BEGIN		SELECT @Table = TableName		FROM #TableListing		WHERE [IndexListingID] = @CurrentTable				EXECUTE dbo.ShowColumnUsage @Table				SET @CurrentTable = @CurrentTable + 1	ENDEND</description><pubDate>Thu, 05 Aug 2010 12:09:45 GMT</pubDate><dc:creator>Douglas Osborne-456728</dc:creator></item><item><title>RE: Find botched constraints, idxs, fks</title><link>http://www.sqlservercentral.com/Forums/Topic833291-1710-1.aspx</link><description>I'm looking for an explanation for some of the abreviations.pk is Primary Keyak is Unique Constraints ??udx is Unique Indexidx is non unique index"+" means that the field is an included field in the indexThe numbers:    x.ywhere x means the "index number" (what is this?)and y means the Index Column IDThe sproc does a good job in showing the relationship between indexing and FK. Thank you.Best regards,Henrik Staun Poulsenwww.stovi.com</description><pubDate>Thu, 05 Aug 2010 01:29:08 GMT</pubDate><dc:creator>henrik staun poulsen</dc:creator></item><item><title>RE: Find botched constraints, idxs, fks</title><link>http://www.sqlservercentral.com/Forums/Topic833291-1710-1.aspx</link><description>An interesting query.I would note that if one is looking for botched foreign keys, one must look for both disabled and enabled but untrusted foreign keys and note them.I'd also have to modify it to run from a single database against columns on another database (with EXEC 'USE &amp;lt;db&amp;gt;; &amp;lt;statement&amp;gt;' if need be).</description><pubDate>Tue, 29 Dec 2009 10:30:06 GMT</pubDate><dc:creator>Nadrek</dc:creator></item><item><title>Find botched constraints, idxs, fks</title><link>http://www.sqlservercentral.com/Forums/Topic833291-1710-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/scripts/Table/68941/"&gt;Find botched constraints, idxs, fks&lt;/A&gt;[/B]</description><pubDate>Fri, 11 Dec 2009 23:29:14 GMT</pubDate><dc:creator>Bill Talada</dc:creator></item></channel></rss>