We help IT Professionals succeed at work.

How to change the default database using SQL Server Management Studio

Medium Priority
418 Views
Last Modified: 2013-12-03
I don't see how to change the default database.

I have an ODBC connection in which I can tell it to use a different database than what the default database is, but if I delete that default database the ODBC connections fail. So I need to change the default database.
Comment
Watch Question

AneeshDatabase Consultant
CERTIFIED EXPERT
Top Expert 2009

Commented:
try this query

exec sp_defaultdb 'LoginName', 'NewDefltDBName'

This works in SQL 2k

Author

Commented:
this ran without an error, but did not seem to work.
Database Consultant
CERTIFIED EXPERT
Top Expert 2009
Commented:
exec sp_defaultdb 'sa', 'msdb'

run the above and logon to ur sql server using 'sa' and check the dbname, it has to be msdb, earlier it was master

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
AneeshDatabase Consultant
CERTIFIED EXPERT
Top Expert 2009

Commented:
Points to aneeshattingal
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.