SQL server 2012: Where are the "ALL SERVER" triggers scripts stored

Viewed 7840

Where would a trigger be stored if I created it to trigger on "ALL SERVER".

CREATE TRIGGER trg_LogonAttempt ON ALL SERVER
FOR LOGON
AS
BEGIN
IF ORIGINAL_LOGIN() = 'dbo'

I would like to be able to find and modify it again if I close it down. I know where triggers are normally saved in the object explorer under table. Thank you.

1 Answers

You can get this from the catalog view in the master database:

USE master;
GO

SELECT name, OBJECT_DEFINITION ([object_id]) 
FROM sys.server_triggers
-- WHERE name = N'trg_LogonAttempt'
;

You can also script it through the UI, as @Michael pointed out - server-level triggers are stored under Instance > Server Objects > Triggers:

enter image description here

Related