July 10, 2008 at 10:20 am
Does anyone have a neat script that can show me all tables with out FK's on them , or can point me in the right direction how to write my own if not ?
many thanks si
July 10, 2008 at 11:32 am
1. check INFORMATION_SCHEMA.TABLE_CONSTRAINTS for those having FK constraints.....
2. then, check sysobjects for those w/o FK.....
Hint: using LEFT JOIN.
*********************************
EDIT:
Actually, you can just query sysobjects.:D
July 10, 2008 at 8:12 pm
try this:
select *
from sys.tables t
Where NOT EXISTS( select * from sys.foreign_keys
Where t.object_id IN (Parent_object_id, Referenced_object_id) )
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
July 14, 2008 at 4:39 am
rbarryyoung (7/10/2008)
try this:
select *
from sys.tables t
Where NOT EXISTS( select * from sys.foreign_keys
Where t.object_id IN (Parent_object_id, Referenced_object_id) )
ahh Im using SQL 2000 but shall bear that in mind 🙂 thank you
July 14, 2008 at 4:39 am
Wildcat (7/10/2008)
1. check INFORMATION_SCHEMA.TABLE_CONSTRAINTS for those having FK constraints.....2. then, check sysobjects for those w/o FK.....
Hint: using LEFT JOIN.
*********************************
EDIT:
Actually, you can just query sysobjects.:D
right going to give this a go .. many thanks 🙂
~si
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply