I am using SQL Server Express 2005.
I have a single database myDB
I have created a Login L-1 with user U-1 on databas myDB.
To connect to database myDB I found 3 ways:
-1(a)-after creating L-1 Login with default database = myDB , I have to create a user U-1 , and when I connected to SQL server , then it connected.
I used this query:
create login L-1 with password='passL1' , default_database = myDB
use myDB
create user U-1 for login L-1
Means, creating a user inside a login , gives the user connect permission implicitly. Am I right ?
-1(b)-I didn’t create any user U-1, but executed this :
use myDB
sp_grantdbaccess L-1
this also made me connect , the reason being that, sql added a user named L-1 implicitly in the myDB database. Am I right?
-1(c)-this time also, I didn’t create any user U-1,but I executed this:
sp_changedbowner L-1
this also made me connect , the reason being that, sql added a user named L-1 implicitly in the myDB database. Am I right?
Now, I want to give the user U-1 created in 1(a) the following permissions:
- Create Logins L-2,L-3
- Create Users U2,U3 which can also connect to database myDB.
How do I do this?
Yes – calling
sp_grantdbaccessorsp_changedbownerwill just implicitly do what you would normally do withCREATE USER– no difference.Calling
CREATE USERexplicitly is just clearer, more obvious what you’re doing etc.Also: don’t use
sp_grantdbaccessanymore – because:Source: Technet on sp_Grantdbaccess
And don’t use sp_changedbowner either – same reason:
Source: Technet on sp_changedbower