Sometimes we need to share data with third parties, but we don't have a completely open database. Therefore, the use of database role authorization can be a good solution to this problem. The following are the SQL statements used in the work. Just take notes.
--Create role role_techdbexec sp_addrole ' role_techdb '--grant ROLE_TECHDB all permissions to Gxjg_jzgjcsjzlb,gxxx_yxsdwjbsjzl table Grant SELECT, Delete,insert,update on GXJG_JZGJCSJZLB to Role_techdbgrant select,delete,insert,update on GXXX_YXSDWJBSJZL to Role_ techdb--Add login zf_login, set password for [email protected], default database is Techdbexec sp_addlogin ' zf_login ', ' [email protected] ', ' techdb ' exec sp_grantdbaccess ' zf_login ', ' zf_login '--add zf_login for role ROLE_TECHDB member exec sp_addrolemember ' role_techdb ', ' zf_ Login
SQL Server database Add role, role authorization