Granting Database Privileges in SQL Server 2008 Using Graphical and Command Tools
To establish an ODBC connection using SQL Server authentication, users require specific database privileges. This article demonstrates how to grant these privileges using both graphical and command-line tools in SQL Server 2008.
Graphical Method (SSMS)
Command-Line Method
To grant specific privileges on a per-table basis, use the GRANT command:
GRANT SELECT, INSERT, UPDATE ON dbo.YourTable TO YourUserName GRANT SELECT, INSERT ON dbo.YourTable2 TO YourUserName GRANT SELECT, DELETE ON dbo.YourTable3 TO YourUserName
To grant broader read permissions, add the user to the default db_datareader role:
EXEC sp_addrolemember N'db_datareader', N'your-user-name'
For write permissions, add the user to the db_datawriter role:
EXEC sp_addrolemember N'db_datawriter', N'your-user-name'
Additional Notes
The above is the detailed content of How to Grant Database Privileges in SQL Server 2008 Using SSMS and T-SQL?. For more information, please follow other related articles on the PHP Chinese website!