What is the most portable 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

Update (for Jakub Januszkiewicz):

If you need to include the schema information, you could also do something like this:

SELECT
    (list of columns)
FROM sys.triggers tr
INNER JOIN sys.tables t ON tr.parent_id = t.object_id
WHERE t.schema_id = SCHEMA_ID('dbo')   -- or whatever you need

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)