October 12, 2009 at 7:10 pm
Comments posted to this topic are about the item Find Foreign Key Tables
October 27, 2009 at 8:02 am
simpler statement
select object_name(referenced_object_id) as PrimaryKeyTable
,object_name(parent_object_id) as ForeignKeyTable
,*
fromsys.foreign_keys
whereobject_name(referenced_object_id) like '%mySearchedPrimaryKeyTable%'
order by object_name(referenced_object_id)
,object_name(parent_object_id)
October 27, 2009 at 12:57 pm
EXEC sp_helpconstraint 'TableName' for single tables is simpler and covers all constraints.
October 28, 2009 at 9:55 am
This URL even helps determine the columns involved in that Foreign Key.
December 18, 2009 at 12:03 pm
This script is a nice starter script. What I see from the script is that it lists all of the foreign keys. After that, you are required to manually create the hierarchy of FKs and table relationships. Building that hierarchy is the time consuming piece.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
January 19, 2010 at 7:38 am
That is correct. This simple tutorial script solves the problem I had and is a sample for you to refactor and write whatever you want.
CirquedeSQLeil is going to write the recusive script that query FK hierarchy and publish here.
Jason
http://dbace.us
😛
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply