I tried creating a user with all privileges but I am getting this error:
Microsoft SQL Server Management Studio
Create failed for User 'Hru'. (Microsoft.SqlServer.Smo)
Additional information:
An exception occurred while executing a Transact-SQL statement or batch.
(Microsoft.SqlServer.ConnectionInfo)'Hru' is not a valid login or you do not have permission. (Microsoft SQL Server, Error: 15007)
Can anybody help me solve this?
2 Answers 2
The error message is stating that SQL Server cannot locate a login named Hiru
, or you do not have the privilege required to create a user.
The SQL Server security model consists1 of a server-level login that provides access at the server level. Logins are then associated to a user inside each database. The user typically has the same name as the login, although that is not required.
Creating a login and user is easy to do with T-SQL, as in:
USE master;
CREATE LOGIN [Hiru] WITH PASSWORD = 'pwd';
USE mydb;
CREATE USER [Hiru] FOR LOGIN [Hiru];
Using a T-SQL script provides more direct control over the process, and allows better troubleshooting.
1 - unless you're using the contained database security model
First create a global login under Security -> Logins
Then add the user in Databases -> Database -> Security -> Users
Explore related questions
See similar questions with these tags.