📜  消息 156,级别 15,状态 1,过程 Restrict_SSMS_For_Other_Users,第 10 行 [Batch Start Line 0] 关键字“ROLLBACK”附近的语法不正确. - 无论代码示例

📅  最后修改于: 2022-03-11 14:56:22.607000             🧑  作者: Mango

代码示例1
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;