标签: execute-as

服务器主体"sa"无法访问当前安全上下文下的数据库"model"

我创建了一个存储过程,它执行一系列需要特殊权限的操作,例如create database,restore database等.我创建了这个存储过程

execute as self
Run Code Online (Sandbox Code Playgroud)

...所以它作为SA运行.这是因为我想给一个没有任何权限的SQL用户只能运行我定义的这些命令.

但是当我运行这个存储过程时,我得到了

The server principal "sa" is not able to access the database "model" under the current security context.
Run Code Online (Sandbox Code Playgroud)

为什么SA无法访问模型数据库?我实际上在SA下运行存储过程中的代码,它运行正常.

sql-server execute-as

7
推荐指数
1
解决办法
1万
查看次数

标签 统计

execute-as ×1

sql-server ×1