11

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

Paul White
95.4k30 gold badges440 silver badges689 bronze badges
asked Aug 8, 2018 at 13:56
0

2 Answers 2

13

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

answered Aug 8, 2018 at 14:46
5

First create a global login under Security -> Logins

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

answered Mar 19, 2019 at 5:01

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.