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
 SQL Server Development (2000)
 Disable and Re-enable FK Constraints

Author  Topic 

JamesT
Yak Posting Veteran

97 Posts

Posted - 2002-03-08 : 13:33:24
I need to be able to loop through a tables FK constraints and disable them. Load data into that table and others then re-enable the constraints. I know that I can use:

ALTER TABLE tbl_name NOCHECK CONSTRAINT constraint_name

To disable the constraint and subsequently reinstate the constraint. How would I determine if there are constraints at all on the table and get the constraint name? I think it will have to be through the system tables but I don't know where to begin. Any pointers would be appreciated.

setbasedisthetruepath
Used SQL Salesman

992 Posts

Posted - 2002-03-08 : 13:51:20
try:

select o.*
from sysconstraints c
inner join sysobjects o on c.constid = o.id

Go to Top of Page
   

- Advertisement -