What is the best way to check whether a trigger exists in SQL Server?

There's also the preferred "sys. Triggers" catalog view: select * from sys. Triggers where name = 'MyTrigger or call the sp_Helptrigger stored proc: exec sp_helptrigger 'MyTableName But other than that, I guess that's about it :-) Marc.

There's also the preferred "sys. Triggers" catalog view: select * from sys. Triggers where name = 'MyTrigger' or call the sp_Helptrigger stored proc: exec sp_helptrigger 'MyTableName' But other than that, I guess that's about it :-) Marc.

Tested and doesn't work on SQL-2000: select * from sys. Triggers where name = 'MyTrigger' Tested and works ok on SQL-2000 and SQL-2005: select * from dbo. Sysobjects where name = 'MyTrigger' and OBJECTPROPERTY(id, 'IsTrigger').

FWIW, your select * from dbo. Sysobjects where name = 'MyTrigger' and OBJECTPROPERTY(id, 'IsTrigger') doesn't work for my correctly-functioning after insert, delete trigger on SQL-2000. The row is there in sysobjects, but OBJECTPROPERTY(id, 'IsTrigger') on its ID (as part of the above or separately just using its raw ID) gives 0.

Checking for xtype = 'TR' or type = 'TR' works. – T.J. Crowder Apr 24 '10 at 16:56.

This works on SQL2000 and above IF OBJECTPROPERTY(OBJECT_ID('{your_trigger}'), 'IsTrigger') = 1 BEGIN ... END.

USE YOUR_DB IF OBJECT_ID('your_trigger') IS NULL BEGIN PRINT 'TR NOT EXISTS' END ELSE BEGIN PRINT 'TR EXISTS' END.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions