t-sql 创建用户并授予执行存储过程的权限
问题说明
我有一个创建数据库、存储过程、视图、表、udf 的脚本.我想包含一个脚本来创建用户user_1"并授予对数据库的执行权限.
I have a script which creates a database, stored procs, views, tables, udf. I want to include a script to create a user 'user_1' and give execute permission on the database.
我尝试按照以下步骤为所有存储的过程创建授权执行命令
I tried following to create grant exec command for all stored procs
declare @permission varchar(max)
select @permission = COALESCE(
@permission '; ' 'Grant Execute on ' name ' user_1',
'Grant Execute on ' name ' user_1')
from sysobjects where xtype in ('P')
exec (@permission)
但是 exec (@permission)
不起作用.它给
But exec (@permission)
does not work. It gives
';' 附近的语法不正确.
incorrect syntax near ';'.
我该如何解决这个问题?
How can I solve this?
正确答案
创建登录:创建服务器级登录.然后...创建用户:让登录帐户附加到您的数据库.然后...授予执行至:授予对数据库中所有 sp 和函数的执行权限.如果您只想授予特定 sps 的权限,请使用Grant Execute ON abc TO xyz".
Create Login: creates the server level login. Then... Create User: lets the Login account attach to your database. Then... Grant Execute To: grants execute rights to ALL of the sp's and functions in your db. Use "Grant Execute ON abc TO xyz" if you only want to grant rights to specific sps.
Create login abacadaba with password='ABVDe12341234';
Create user abacadaba for login abacadaba;
Grant Execute to abacadaba;
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tangibggb
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
希伯来语的空格句子标记化错误
it1352 06-22 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20