user3008146
user3008146

Reputation:

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

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.

Upvotes: 8

Views: 8977

Answers (1)

Aaron Bertrand
Aaron Bertrand

Reputation: 280431

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

Upvotes: 15

Related Questions