10

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?

enter image description here

0

2 Answers 2

12

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

5

First create a global login under Security -> Logins

Then add the user in Databases -> Database -> Security -> Users

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.