Ease your Visual Studio development with a SQL Server alias

A quick little tip on how to manage connection strings in your applications with a SQL Alias that you can create with “SQL Server Configuration Manager”
SQL Server connection strings in app.config

If you have a specific connection string in your application.config like

    connectionString="Data Source=MyLittleLaptop\SQLExpress; 
     Initial Catalog=Northwind; Persist Security Info=True;
     User ID=userName;Password=password"



In order to avoid

#1 merge conflicts on every check in

#2 to remember to exclude the app.config (or web.config) on every check in

Figure: Exclude the app.config because I needed to change the DB connectionstring to “.\SQLExpress”

#3 getting beaten by other developers


Create a SQL Alias with SQL Server Configuration Manager

  1. Open SQL Configuration Manager
  2. Go to “SQL Native Client 10.0 Configuration (32bit)”
    My client is a 32bit process

  3. Create a new alias
    In my case called: “.\USTER” since that is DB name that we agreed on
    Figure: “.\USTER” points to “.\MSSQL” via Named Pipes
    Figure: “.\USTER” points to “.\MSSQL” via Named Pipes
  4. Ready to rock!



Make sure to enable “Named Pipes” for that SQL instance


Happy days in your development team!

BTW: If you deploy your application to different environments you can and should change server names via “XML transforms” or “XML Parametrizations”


Rui said...

Thanks for this

We do have this problem.

#3 happens frequently :)

Peter Gfader said...

I had similar experience in this order: #1 and #2... and finally #3 :-)

Basil Figueroa said...

This article is based on Microsoft SQL Server, and Transact-SQL, but that is of little importance, as most of the concepts can be equally applied to other database technologies.

Peter Gfader said...

Hi Basil

>>as most of the concepts can be equally applied to other database technologies.
In other database technologies you need to use different techniques.
Can you share some?

DNS entries? VMWare virtualization that points to different servers...

Digi07 said...

Thanks for sharing such valuable information.

Post a Comment

Latest Posts

Popular Posts