T-SQL如何授予用户角色

时间:2021-11-23 01:29:56

After creating roles and granting privileges to them, I want to grant the privileges of a specified role to a user, how to do with it? I tried grant to , but failed.

在创建角色并授予它们特权之后,我想授予用户特定角色的特权,如何处理?我试图说服格兰特,但失败了。

2 个解决方案

#1


44  

EXEC sp_addrolemember 'db_owner', 'JohnJacobs'

#2


41  

Because BOL shows sp_addrolemember has been deprecated, if you are using SQL Server 2012 you may want to use:

由于BOL显示sp_addrolemember已经被弃用,如果您正在使用SQL Server 2012,您可能想要使用:

ALTER ROLE <role_name> ADD MEMBER <user_name>

#1


44  

EXEC sp_addrolemember 'db_owner', 'JohnJacobs'

#2


41  

Because BOL shows sp_addrolemember has been deprecated, if you are using SQL Server 2012 you may want to use:

由于BOL显示sp_addrolemember已经被弃用,如果您正在使用SQL Server 2012,您可能想要使用:

ALTER ROLE <role_name> ADD MEMBER <user_name>