How to disable SQL Server Management Studio for a user

前端 未结 11 2185
梦毁少年i
梦毁少年i 2021-01-02 13:49

Is there a way to prevent users from getting into SQL Server Management Studio so that they can\'t just edit table rows manually? They still need to access the tables by ru

11条回答
  •  再見小時候
    2021-01-02 14:52

    You can use a trigger.

    CREATE TRIGGER [TR_LOGON_APP]
    ON ALL SERVER 
    FOR LOGON
    AS
    BEGIN
    
       DECLARE @program_name nvarchar(128)
       DECLARE @host_name nvarchar(128)
    
       SELECT @program_name = program_name, 
          @host_name = host_name
       FROM sys.dm_exec_sessions AS c
       WHERE c.session_id = @@spid
    
    
       IF ORIGINAL_LOGIN() IN('YOUR_APP_LOGIN_NAME') 
          AND @program_name LIKE '%Management%Studio%' 
       BEGIN
          RAISERROR('This login is for application use only.',16,1)
          ROLLBACK;
       END
    END;
    

    https://www.sqlservercentral.com/Forums/1236514/How-to-prevent-user-login-to-SQL-Management-Studio-#bm1236562

提交回复
热议问题