Wednesday, April 1, 2015

SQL Server Alias

Our team of several developers is building an application connects to SQL Server.  Well all have local instances of SQL Server, but the connection strings vary from developer to developer.  Rather than having each developer use a different connection string, we figured we'd configure SQL Server Aliases on each of our PC's so that we could all use the same connection string.

This approach worked well.  It took a little fiddling to get my local alias working, so I figured I document the steps here.
First, you'll need to open up SQL Server Configuration Manager, which is one of the SQL Configuration Tools listed on the Start menu.


Next, you'll need to check the protocols that are enabled for your local instance.  These settings are located under the SQL Server Network Configuration.  In my case, I found that only Shared Memory was enabled.  I went the route of tying my alias to a TCP port so I enabled TCP/IP and chose port 9020.


I enabled TCP/IP by clicking on the TCP/IP row, then changing the Enabled status on the Protocol tab of the Properties window.  I also made sure that Listen All was set to 'Yes'.


Then I chose port 9020 on the IP Addresses tab under the Listen All section.



After turning on TCP/IP I added an alias.  I pointed my local instance to the name 'localsql' using port 9020. 

All Done!


No comments:

Post a Comment