Query to find orphan tables

The following query will fetch the tables that doesn’t have relationships.

Select ST.[Name] as “Orphan Tables”

from Sys.Foreign_Keys as SFK Right Join Sys.Tables as ST

On ST.object_id = SFK.parent_object_id Or

ST.object_id = SFK.referenced_object_id

Where SFK.type is null

The URI to TrackBack this entry is: http://dayananthan.wordpress.com/2008/03/13/query-to-find-orphan-tables/trackback/

RSS feed for comments on this post.

Leave a Comment