How to set user database to default database

  • Experts,

    If i open QueryAnalyzer, It shows the master database as the default database.

    I want to change it to any user database. is it possible ?

    Thanks in Advance.

    karthik

  • You can set this using sp_defaultdb, or by opening the login's properties window in EM.

    HTH,

    Simon

  • In Enterprise Manager, expand the relevant server and get to the appropriate login under the Security folder. Right-click on the login and get the properties. Under the General tab select the database under Defaults.

    For SQL Server 2005, it is pretty much the same in Management Studio; you have the Default Database option.

  • Is there any restrction to use sp_defaultdb ? Because i have dbo permission only.

    karthik

  • I can't remember the details - I think you can only change the default db for your own login unless you are sysadmin - it should tell you in BOL.

  • do you have any idea why sql server is showing master database as the default one ? why can't it shows Model or tempdb ? is there any reason ?

    karthik

  • The reason it shows master as the default database is because master is the default "default" database. When your login was set up, someone didn't take the time to change the default database for it and hence, master is its default database.

    I can think of no good reason to set tempdb or model to the default database. What database is this user going to be using most? Assign that database as the default. If this person is just in training, Northwind or pubs could be used as the default.

    Steve

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply