Here is a nice little bit of T-SQL that will help with your scripting woes.
Ever wanted to disable all triggers in a database so you can merrily import or merge data and other such tasks?
Well here is what you can do, it simply disables all triggers for all tables in your active database and then enables them again at the end of your changes.
---------------------------------------------------------- EXEC sp_MSforeachtable 'ALTER TABLE ? DISABLE TRIGGER ALL' ---------------------------------------------------------- -- Write some SQL Modifications here --------------------------------------------------------- EXEC sp_MSforeachtable 'ALTER TABLE ? ENABLE TRIGGER ALL' ---------------------------------------------------------
Hope this helps,
Stefan.
For more Web Code, ASP.NET, SQL Server and other development tips, please check back here at webcodeblog.com often.