I created a login named mylogin with password= ‘pass_1’
Then i logged into sql server using this login & tried to create a database , which gave the error that permission denied.
Then i executed this : sp_addsrvrolemember ‘mylogin’, ‘dbcreator’
Then, again I logged into sql server using above login & tried to create a database, this time the database was created successfully
This was because I added the dbcreator server role for the login.
But, then i created a USER myloginuser for LOGIN mylogin ,
then executed this query:
execute as user = ‘myloginuser’
then again i tried to create a database, but it failed. why so?
when the login MYLOGIN to which the user MYLOGINUSER is associated has the permission to create a database then why does the user does not have the permission? then whats the solution for this? do i have to grant permission to the user separately irrespective of the permissions granted to the login?
also, a user which is created for a login , have to be created inside a database? is it necessary?
The default user for the LOGIN [mylogin] was mylogin (which was created executing
Hence this mylogin user had the db create permission. But you have created a MYLOGINUSER for the same Login. So the existing user mylogin was set to orphaned user, hence the mylogin Login dropped the db creator permission.