📅  最后修改于: 2022-03-11 14:56:22.607000             🧑  作者: Mango
CREATE TRIGGER Restrict_SSMS_For_Other_Users
ON ALL SERVER
FOR LOGON
AS
BEGIN
IF SUSER_NAME() <> 'MyDomain\PrivilegedUser' AND EXISTS (SELECT *
FROM sys.dm_exec_sessions
WHERE session_id = @@SPID
AND program_name IN (N'Microsoft SQL Server Management Studio - Query')
ROLLBACK;
END;