0

我想拒绝从 SSMS 以 SA 身份访问数据库,但允许他们在以 SA 身份登录时通过其他应用程序进行更改。我使用了以下代码,但系统抛出错误。请建议我更正以下代码。

CREATE TRIGGER [Tr_ServerLogon]
ON ALL SERVER FOR LOGON
AS
BEGIN
declare @appname VARCHAR(512)
SET @appname = APP_NAME()

if ('.Net SqlClient Data Provider'=@appname)
GRANT DELETE ON [dbname].[dbo].[tablename] TO [username]
else
DENY DELETE ON [dbname].[dbo].[tablename] TO [username]

END
GO
4

0 回答 0