Tuesday, March 20, 2012

problem on alter table

I would like to disable triggers of all tables. How can I do that? I can get
the names of table and trigger from sysobjects. But how can I
programmatically to replace the table name and trigger name from the ALTER
TABLE command?
ALTER TABLE table1 DISABLE TRIGGER trigger1
Thanks.Hi
-- to diable all
EXEC sp_MSForEachTable N'ALTER TABLE ? DISABLE TRIGGER ALL'
GO
-- to enable all
EXEC sp_MSForEachTable N'ALTER TABLE ? ENABLE TRIGGER ALL'
GO
"joeau" <joeau@.discussions.microsoft.com> wrote in message
news:7A084773-C0CC-4543-99A8-B563C44EDF7F@.microsoft.com...
> I would like to disable triggers of all tables. How can I do that? I can
get
> the names of table and trigger from sysobjects. But how can I
> programmatically to replace the table name and trigger name from the ALTER
> TABLE command?
> ALTER TABLE table1 DISABLE TRIGGER trigger1
> Thanks.|||Thanks Dimant.
It works OK but I cannot find this store procedures on SQL Book Online. Why?
Thank you.
"Uri Dimant" wrote:

> Hi
> -- to diable all
> EXEC sp_MSForEachTable N'ALTER TABLE ? DISABLE TRIGGER ALL'
> GO
> -- to enable all
> EXEC sp_MSForEachTable N'ALTER TABLE ? ENABLE TRIGGER ALL'
> GO
>
> "joeau" <joeau@.discussions.microsoft.com> wrote in message
> news:7A084773-C0CC-4543-99A8-B563C44EDF7F@.microsoft.com...
> get
>
>|||Hi
Its not documented from MS. Actually it may have some changes in the future
version of the SQL Server , so I'd not recommend you to use it in
production.
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:eK94OOrMFHA.3076@.TK2MSFTNGP14.phx.gbl...
> Hi
> -- to diable all
> EXEC sp_MSForEachTable N'ALTER TABLE ? DISABLE TRIGGER ALL'
> GO
> -- to enable all
> EXEC sp_MSForEachTable N'ALTER TABLE ? ENABLE TRIGGER ALL'
> GO
>
> "joeau" <joeau@.discussions.microsoft.com> wrote in message
> news:7A084773-C0CC-4543-99A8-B563C44EDF7F@.microsoft.com...
> get
ALTER
>

No comments:

Post a Comment