Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to change the default database using SQL Server Management Studio

Posted on 2006-03-22
7
Medium Priority
?
400 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.
0
Comment
Question by:kzsigo
  • 3
4 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 16265998
try this query

exec sp_defaultdb 'LoginName', 'NewDefltDBName'

This works in SQL 2k
0
 

Author Comment

by:kzsigo
ID: 16308081
this ran without an error, but did not seem to work.
0
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 200 total points
ID: 16308298
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

0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 16782162
Points to aneeshattingal
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question