问题
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:
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:
来源:https://stackoverflow.com/questions/20404097/sql-server-2012-where-are-the-all-server-triggers-scripts-stored