Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Administration - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 6525

Server level trigger to log activity and rollback after logging information

$
0
0
I use following trigger to stop user "smith" if he try to connect through SSMS to My Server:[code="sql"]create TRIGGER [trg_connection_MyServer]ON ALL SERVER WITH EXECUTE AS 'Smith'FOR LOGONASBEGINIF ORIGINAL_LOGIN()= 'Smith' begin if exists (SELECT 1 FROM sys.dm_exec_sessions WHERE (program_name like 'Microsoft SQL Server%' and original_login_name = 'Smith') ) ROLLBACK; endEND;[/code]I want to log this information or send emal incase, this user try to connect through SSMS, so that I can catch him. Let me know how can I do this, if I use insert command it rollsback everything and I can't do any activity.Shamshad Ali

Viewing all articles
Browse latest Browse all 6525

Trending Articles