Wednesday, March 7, 2012

Deferring constraint checking in a transaction

Hello,
Is there a way to defer constraint checking during a sql server database
data import transaction?
I can turn constraints off in sql with an alter table command, but this
requires adding the user to the db_ddladmin group which I'd rather they
didn't belong to.Hi,
you can disable all / certain constraint defined on tables:
http://sqljunkies.com/WebLog/roman/...01/30/7037.aspx
-- Disable all table constraints
ALTER TABLE MyTable NOCHECK CONSTRAINT ALL
-- Enable all table constraints
ALTER TABLE MyTable CHECK CONSTRAINT ALL
-- Disable single constraint
ALTER TABLE MyTable NOCHECK CONSTRAINT MyConstraint
-- Enable single constraint
ALTER TABLE MyTable CHECK CONSTRAINT MyConstraint
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"shmeian" <shmeian@.discussions.microsoft.com> schrieb im Newsbeitrag
news:BC396313-25DB-45FA-A3D2-265109246024@.microsoft.com...
> Hello,
> Is there a way to defer constraint checking during a sql server database
> data import transaction?
> I can turn constraints off in sql with an alter table command, but this
> requires adding the user to the db_ddladmin group which I'd rather they
> didn't belong to.
>

No comments:

Post a Comment