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
Are trigger names forced to be unique in SQL server?
As triggers are by definition applied to a specific table would it not be more efficient to restrict the search to only the table in question?
We have a database with over 30k tables in it all of which have at least one trigger and may have more (bad DB design - quite probably, but it made sense years ago and didn't scale well)
I use
SELECT * FROM sys.triggers
WHERE [parent_id] = OBJECT_ID(@tableName)
AND [name] = @triggerName