notebook/IT/SQL/SCRIPTS SQL QSA ORSYS/Demo déclencheur DDL LOGON.sql
2020-11-26 18:38:25 +01:00

14 lines
311 B
SQL

CREATE TRIGGER E_LOGON_LIMIT_SA
ON ALL SERVER
FOR LOGON
AS
BEGIN
IF EXISTS(SELECT 1
FROM sys.dm_exec_sessions
WHERE is_user_process = 1
AND ORIGINAL_LOGIN()= 'sa'
AND original_login_name = 'sa'
HAVING COUNT(*) > 1)
ROLLBACK;
END;