October 7, 2004 at 9:00 am
Hi!
Tried to find out this from BOL, but could not. Is there a way to disable a trigger with TSQL?
Thanks.
October 7, 2004 at 11:52 am
It's buried in the ALTER TABLE command and can be hard to find.
For all of them:
ALTER TABLE tablename
DISABLE TRIGGER ALL
For a specific trigger:
ALTER TABLE tablename
DISABLE TRIGGER triggername
K. Brian Kelley
@kbriankelley
October 10, 2004 at 9:30 pm
Brian,
Is there some undocumented - hard to find command to disable instead-of triggers on views - apart from dropping the trigger?
Thanks,
Win
October 11, 2004 at 3:38 am
I couldn't find a command to do that, but this proc will work. Please forgive the terrible formatting - I can't persuade this post to be neat...
GO
SET ANSI_NULLS ON
GO
AS
(select ID from sysobjects where Parent_obj =
(Select Id from sysobjects where name = @Table) and type = 'tr')
and Text like '%Instead Of Insert%As%'
IF @Enable = 1
set @Sql = 'alter table '+@Table+' enable trigger '+@Name
ELSE
set @Sql = 'alter table '+@Table+' disable trigger '+@Name
print @Sql
EXEC (@Sql)
(select ID from sysobjects where Parent_obj =
(Select Id from sysobjects where name = @Table) and type = 'tr')
and Text like '%Instead Of Update%As%'
IF @Enable = 1
set @Sql = 'alter table '+@Table+' enable trigger '+@Name
ELSE
set @Sql = 'alter table '+@Table+' disable trigger '+@Name
(Select ID from sysobjects where Parent_obj =
(Select Id from sysobjects where name = @Table) and type = 'tr')
and Text like '%Instead Of Delete%As%'
IF @Enable = 1
set @Sql = 'alter table '+@Table+' enable trigger '+@Name
ELSE
set @Sql = 'alter table '+@Table+' disable trigger '+@Name
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
October 11, 2004 at 4:11 am
Steven,
Thanks for the proc, let's hope there will be a command in Yukon
Win
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply