DotNet Mirror
  DNM facebook   DNM Google+   DNM Twitter   

Set Default Database with SQL Server Management Studio

By Ashok Nalam on 27 Mar 2014 | Category: SQL Server | Tagged: database user tsql SQL Server 
  Discuss Add Comment   |  
Add rating Rate this resource   

Introduction

Every time we connect to SQL Server Management Studio by default it connects to "master" database. In day to day development, if you are working with one of your project database it will be difficult to switch to your database every time using the "USE [YourDBName]" statement or selecting database from dropdown list.

The following tip shows how to set default database using "Login Properties" window and T-SQL.

Set Using Login Properties:

Open SQL Server Management Studio > View >  Object Explorer(F8) > Security > Logins > Right Click on Login > Properties > Under General tab you can find "Default Database" dropdown > Select your project database.

SQL Server Login Properties - Set Default Database
Fig: Login Properties - Set Default Database 

Set using T-SQL

Exec sp_defaultdb @loginame='sa', @defdb='DotNetMirrorDB'

Hope it saves your time!
  Discuss Add Comment    
Add rating Rate this resource   
About the Contributor
Member Since : 10 Dec 2012
Member Points (Level) : 9526  (Professional)
Location : INDIA
Home Page : http://dotnetmirror.com
About : I am admin of this site.
Rate this resource
 
Add your Comment
Name Email WebSite
Captcha Refresh


Comments (0)
No comments found, click here to add comment.
 
cheap jordans|wholesale air max|wholesale jordans|wholesale jewelry|wholesale jerseys