Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have developer edition from SQL Server 2008, but now I have a piece of software with a hardcoded connection string:

Data Source=.\SQLEXPRESS;Initial Catalog=db;User Id=sa;Password=1234;

Now I tried adding an Alias in the configuration tool to SQLEXPRESS, but it just doesn't want to use this new alias.

I enabled TCP/IP and restarted the service.

share|improve this question
    
Do you know what type of application it is? Is it a .NET application in which case you have an app.config or web.config file? –  squillman Feb 17 '11 at 13:17
    
Hardcoding the connection string (including username and password)? WHY do people keep doing such awful things?!? –  Massimo Mar 19 at 1:21
add comment

1 Answer

up vote 8 down vote accepted

Follow these steps to add an alias:

  1. Open SQL Server Configuration Manager
  2. Expand SQL Native Client Configuration
  3. Right-click Aliases and select New Alias...
  4. On the New Alias window:
    • Enter .\SQLEXPRESS for the Alias Name.
    • Select the appropriate protocol (e.g., Named Pipes)
    • Enter . for the server name (that's equivalent to localhost).
  5. Click on OK to make the change.

Changing the HOSTS file to include a setting for SQLEXPRESS will only redirect DNS lookups for a machine called SQLEXPRESS to the specified IP address. That will not cause .\SQLEXPRESS to resolve to the localhost SQL instance.

share|improve this answer
1  
Great answer! I was just about to start using explicit port numbers and so on when I happened upon this answer. This solved my problems perfectly. Thank you! :) –  wasatz Oct 29 '13 at 13:50
1  
If you are using 64-bit Windows you might need to create the alias in both the 32-bit and 64-bit SQL Native Client Configuration. –  Tod Thomson Jun 4 at 1:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.