debugsqlModerate
SQL Server Error while creating User
Viewed 0 times
errorwhilesqlcreatinguserserver
Problem
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?
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?
Solution
The error message is stating that SQL Server cannot locate a login named
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:
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
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
Code Snippets
USE master;
CREATE LOGIN [Hiru] WITH PASSWORD = 'pwd';
USE mydb;
CREATE USER [Hiru] FOR LOGIN [Hiru];Context
StackExchange Database Administrators Q#214400, answer score: 12
Revisions (0)
No revisions yet.