Nocheck
Apr 9, 2004I need to insert data into a table..please advise SQL Syntax on how to disable and enable constraints and triggers on the table before and after the inserts!
Thanks..
I need to insert data into a table..please advise SQL Syntax on how to disable and enable constraints and triggers on the table before and after the inserts!
Thanks..
SQL CE does not seem to support WITH NOCHECK constraint when altering the table to add a foreign key. How can I work around this?
View 3 Replies View RelatedIs there away to get the SQL FK constrain to trust old data when the FK is created with NoCheck.?
Some things to ponder
- Assume the table where the FK is created is too large and cant afford a significant down time, but still need the query optimizer to trust the data in the FK for optimal query plans.
- As pre-deploy script will validate the older data in the FK columns for consistency
Is a NOCHECK constraint supported in CE 3.5? The keyword is listed in the 3.5 BOL but when attempting to ALTER TABLE using WITH NOCHECK the statement fails.
If it is not supported then is there a work around for it?
TIA
Hi.I'm getting errors like this when I try to run an upgrade script I'm trying towrite/test:altering labels to length 60Server: Msg 5074, Level 16, State 4, Line 5The object 'ALTPART_ANNOT_ANNOTID_FK' is dependent on column 'label'.I used this to bracket my script:sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"gosp_msforeachtable "ALTER TABLE ? DISABLE TRIGGER all"go/* updates here */sp_msforeachtable @command1="print '?'",@command2="ALTER TABLE ? CHECK CONSTRAINT all"gosp_msforeachtable @command1="print '?'",@command2="ALTER TABLE ? ENABLE TRIGGER all"goI guess the alter table nocheck constraint isn't disabling the fk'scompletely?Is there a way around this, or do I manually have to do the constraintdropping/recreating?ThanksJeff Kish
View 3 Replies View RelatedI wanted to turn off 'Enforce Foreign Key Constrain' using SQL. However, it did not work on the SQL Server 2005 database.
For example, running following SQL in Management Studio, and the result showed that 'Enforce Foreign Key Constrain' property for the newly created constraint was still enabled.
ALTER TABLE [dbo].[Tags] WITH NOCHECK ADD CONSTRAINT [FK_Tags_ChannelID] FOREIGN KEY([ChannelID]) REFERENCES [dbo].[Channels] ([ID])
Does anybody know any way to get around with this problem. It is quite important for my software.
Ps. with the SP1, problem remains the same.