Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Programmatically identify if a FK is disabled?

Author  Topic 

tfountain
Constraint Violating Yak Guru

491 Posts

Posted - 2005-09-29 : 22:39:32
Is there anyway to identify using T-SQL if a foreign key is disabled or not? I have a requirement to disable all foreign keys for a heavy delete procedure but at the end I want to reenable all foreign keys, but only if I disabled them. IOW, if they were disabled prior to me running my script I don't want to reenable them.

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-09-29 : 22:42:07
SELECT * FROM sysobjects WHERE type='F' AND OBJECTPROPERTY(id, 'CnstIsDisabled')=1
Go to Top of Page

tfountain
Constraint Violating Yak Guru

491 Posts

Posted - 2005-09-29 : 22:50:06
quote:
Originally posted by robvolk

SELECT * FROM sysobjects WHERE type='F' AND OBJECTPROPERTY(id, 'CnstIsDisabled')=1



You rock. Thank you Mr. Obvious!

You'll only get that if you've ever heard the Bob & Tom radio show :).
Go to Top of Page
   

- Advertisement -