Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Default DB 2

Status
Not open for further replies.

password99

Technical User
Jul 19, 2002
122
US
How do I change the Default DB of a user in transact SQL.

I am trying to
add a new user who will be the owner of the DB X
and whose default db will be the DB X.

Here is what I have done so far:

sp_addlogin 'user', 'pass', 'master'
use X
EXEC sp_changedbowner 'user'

Now how do I default the DB to be X for user?

Is there a better way of creating a new user who is owner of the DB and also his default DB is X?

THANKS FOR YOUR HELP..I REALLY APPRECIATE IT.



 
Use sp_addlogin. In your example, you created a login with the default database of MASTER. Why didn't you just do:

sp_addlogin 'user', 'pass', 'X'

Then make them dbo.

-SQLBill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top