SQL Server 2005 中的内置数据库角色允许执行存储过程吗?
在 SQL Server 2005 中,有内置的角色:
db_datareader
db_datawriter
等等
是否有任何角色可以让用户执行存储过程?
我不想使用 db_owner,因为这将允许删除和更新,而我不需要。我唯一需要的权限是:
选择
执行
In SQL Server 2005, there are built in roles:
db_datareader
db_datawriter
etc.
Is there any role that lets a user execute an stored proc?
I don't want to use db_owner, because that will permit deletion and updates, which I don't need. The only permissions I need are:
SELECT
EXECUTE
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
看看这篇文章。它可能会为您提供一个有趣的想法来快速完成此操作。
该文章中使用的代码:
Take a look at this article. It may provide you an interesting idea to do this quickly.
Code used in that article:
现在,如果您重新启动 SQL Server Management Studio,当您单击“安全”->“登录”部分中的“用户映射”页面时,您将看到“db_executor”出现在角色列表中。只需添加用户,或者您可以手动执行此操作:
Now, if you restart SQL Server Management Studio, when you click on the "User Mapping" page in the Security->Logins section, you'll see "db_executor" appear in the roles list. Just add the user or you can do it manually:
不,我不认为存在数据库或服务器角色 - 您必须向用户精细地授予相关存储过程的执行权限。
No, I don't believe that there is a database or server role - you have to grant the execute permission granularly to the user for the relevant stored procedures.
为了扩展答案,一般要点是创建一个数据库角色并向该角色分配权限。为此,您需要一些奇特的动态 SQL,例如:
此代码将 EXECUTE 授予存储过程和标量函数,并将 SELECT 授予返回 TABLE 类型的用户定义函数。
To expand on the answer, the general gist is to create a database role and assign permissions to that role. In order to do that, you need some fancy dynamic SQL such as:
This code will grant EXECUTE to stored procedures and scalar functions and SELECT to user-defined functions that return a TABLE type.