30 August 2012

Visual Studio 2012: Change default SQL Server Instace

Visual Studio 2012 Database Project / Sql Server data tools (SSD ) installs and uses a SQL Server Express version named LocalDB for it's operations by default.

LocalDB is created specifically for developers and is a fast, lightweight SQL Server instance that requires minimal management or configuration.

This scenario is great is you don't have a SQL Server instance to develop.

When a object is open, like for example a store procedure, and you execute the code Visual Studio 2012 will connect to LocalDB and there is no option to connect to other database. The solution is to change the default SQL Server Instance used by Visual Studio 2012:

1) On the menu, choose Tools-> Options -> Database tools
2) On the data connections enter the SQL server Instance name that you want to use
3) Press OK


Close all the database project files you have open on Visual Studio and the configuration is done.

6 comments:

Anonymous said...

This doesn't appear to work. Despite doing this, my database project still defaults to LocalDB. Not sure if this is a bug in VS or what. Any advice?

Rui said...

It depends what you have done.
You may also need to go to the database project properties and in Debug press Edit on the Target Connection String.
Define the connection string and it should all work as expected.

Anonymous said...

Hi Rui

Thanks this did help. I however apply code to dev, test and live. In 2010 I had the option to select the server, is this possible with 2012 as I don't want to keep changeing the default connection screen in properties of the project

Thanks

Mark

Rui said...

From what I know Visual studio 2012 database project removed that option.

Anonymous said...

How to do this in visual studio 2013, any idea?
I have been trying to remove the default from local db to sql express. it doesn't work

Rui said...

I am using Visual Studio 2012 for now.
I don0t have Visual Studio 2013 installed yet, but if you find de solution post it here. It may help others.