2012年3月19日星期一

Disbale Forignkey

hi

how can disbale forignkey in sql-server2005,

You cannot disable foreign key in SQL Server 2005 but you can disable it per table, so run a search for ALTER TABLE DROP CONSTRAINT in SQL Server BOL(books online). Hope this helps.

http://msdn2.microsoft.com/en-us/library/ms190273.aspx

(DROP { [ CONSTRAINT ] constraint_name | COLUMN column_name }
Specifies that constraint_name or column_name is removed from the table. Multiple columns and constraints can be listed. DROP COLUMN is not allowed if the compatibility level is 65 or earlier. For more information, see sp_dbcmptlevel (Transact-SQL) ).

|||

Thanks

But i want to change that for some time after i want to restore that key that how can is possible using alter constraint

|||

That is also covered in the link I gave you see the text below some restrictions apply. Hope this helps.

({ CHECK | NOCHECK } CONSTRAINT

Specifies thatconstraint_name is enabled or disabled. This option can only be used with FOREIGN KEY and CHECK constraints. When NOCHECK is specified, the constraint is disabled and future inserts or updates to the column are not validated against the constraint conditions. DEFAULT, PRIMARY KEY, and UNIQUE constraints cannot be disabled.)

没有评论:

发表评论