How to create a user and grant permissions in SQL Server?
To create a user and grant permissions in SQL Server, you can follow these steps:
- Connect to the SQL Server database engine by logging in with an account that has administrator privileges.
- Open a new query window and run the following command to create a user:
- Create a login with the username [username] and password ‘password’.
- After creating a user, you can assign a database user to that user and grant appropriate permissions by executing the following command:
- Use the database name and create a user for login with the specified username.
- Grant permission to users, allowing them to use the GRANT statement.
- Give [username] permission to select, insert, update, and delete data on [table name].
- Different permissions can be allocated to users based on their needs.
Note: When executing the above command, please replace [username], [password], [database name], and [table name] with actual values.