MSSQL grant权限

--创建登录名
create login test_user with password='123456a.';
--创建用户
create user test_user for login test_user with default_schema=dbo;

--给用户test_user在GroupTree_gtr表分配具有查询,插入,更新的权限,但是没有删除得权限。
grant select,insert,update on GroupTree_gtr to test_user WITH GRANT OPTION


--icpdb_user具有操作数据库MRP_HouseDB的所有权限
grant all on  MRP_HouseDB to test_user with grant option

--运行sp_helpprotect来看看GroupTree_gtr表格上哪些人有哪些权限
Exec sp_helprotect GroupTree_gtr

use [oa_ecology]
exec sp_addlogin 'testuser','testuser.123','oa_ecology'       --添加只允许访问指定表的用户
exec sp_grantdbaccess 'testuser'                                   --添加到数据库
GRANT SELECT , INSERT , UPDATE ,delete, EXECUTE  TO testuser       --授与用户 权限 EXECUTE 是执行存储过程的权限。

grant create table,create view,create function,create PROCEDURE
to testuser  WITH GRANT OPTION;

原文地址:https://www.cnblogs.com/Snowfun/p/4894255.html