SQL语句创建登录名,数据库用户,数据库角色及分配权限:

 1 --通过sp_addlogin创建登录名
 2 execute sp_addlogin 'zhangsan','112233' 
 3 
 4 use test
 5 go
 6 
 7 --指定登录名为zhangsan,并且创建test数据库中的用户zzx
 8 execute sp_grantdbaccess 'zhangsan','zzx' 
 9 
10 --授予用户zzx拥有businessDeal表的select权限
11 grant select on businessDeal to zzx
12 
13 --添加数据库角色
14 execute sp_addrole 'work'
15 
16 --添加角色为work的成员zzx
17 execute sp_addrolemember 'work','zzx'
18 
19 --设置角色work拥有BusinessDeal表的update权限
20 grant update on BusinessDeal to work
21 


原文地址:https://www.cnblogs.com/xFight/p/1652099.html