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

后端 未结 9 1788
醉酒成梦
醉酒成梦 2020-12-14 05:50

I\'m looking for the most portable method to check for existence of a trigger in MS SQL Server. It needs to work on at least SQL Server 2000, 2005 and prefe

9条回答
  •  悲&欢浪女
    2020-12-14 06:07

    Tested and doesn't work on SQL Server 2000:

    select * from sys.triggers where name = 'MyTrigger'
    

    Tested and works ok on SQL Server 2000 and SQL Server 2005:

    select * from dbo.sysobjects
    where name = 'MyTrigger' and OBJECTPROPERTY(id, 'IsTrigger')
    

提交回复
热议问题