Scenarios of Use:
- We may want to redirect the connection of an existing application to a different database server without modifying the connection string which might be needed if the database has been moved to a different server and previously used server is no more there.
- We don’t want to expose the actual server name but will offer the alias of that server to connect to.
- There are some applications which do not allow to specify the named instance for its connection. In that case we can specify an alias for that servername\instancename.
Creating an alias:
Open up the SQL Server Configuration Manager (Start->Programs->Microsoft SQL Server 2005->Configuration Tools). In the left pane expand SQL Native Client Configurations, right click on Aliases and click on New alias.
Window for setting up a new alias will be opened up.
In the Alias Name field specify the desired name of the alias, in Server field specify the name of the server (along with the instance name if it is not default instance), specfiy the port like 1433 or just leave this field blank.
Click OK. This will create a new alias for your SQL server instance.
Connecting using Alias:
This created alias can be referred in any connection string, while connecting directly through management studio and also in the SQL Server Agent to connect to server using alias.
Note: There is no need to restart the sql service to make this alias active.