我想拒绝从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