更新时间:2021-10-11 16:06:57
这是一个两步过程:
您需要根据该用户的 Windows 帐户为该用户创建一个登录到 SQL Server 的登录
you need to create a login to SQL Server for that user, based on its Windows account
CREATE LOGIN [<domainName>\<loginName>] FROM WINDOWS;
您需要授予此登录权限才能访问数据库:
you need to grant this login permission to access a database:
USE (your database)
CREATE USER (username) FOR LOGIN (your login name)
一旦您的数据库中有该用户,您就可以为其授予任何您想要的权限,例如您可以为其分配 db_datareader
数据库角色以读取所有表.
Once you have that user in your database, you can give it any rights you want, e.g. you could assign it the db_datareader
database role to read all tables.
USE (your database)
EXEC sp_addrolemember 'db_datareader', '(your user name)'