Home
%3CLINGO-SUB%20id%3D%22lingo-sub-383200%22%20slang%3D%22en-US%22%3EConnection%20Alias%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-383200%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3E%20First%20published%20on%20MSDN%20on%20Jan%2007%2C%202007%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CP%3ESQL%20Server%20client%20stack%20has%20a%20facility%20to%20let%20user%20define%20connection%20aliases.%20Connection%20Alias%20can%20usually%20help%20user%20make%20connection%20eaiser%2C%20faster%20and%20with%20more%20convenience.%20However%2C%20if%20it's%20not%20used%20properly%2C%20it%20sometimes%20results%20in%20connectivity%20issues%20which%20might%20be%20difficult%20to%20isolate.%3C%2FP%3E%0A%20%20%3CP%3EUser%20can%20take%20advantage%20of%20connection%20alias%20in%20both%20MDAC%20and%20SNAC.%20The%20information%20is%20saved%20in%20registry.%20There%20are%20two%20tools%20can%20be%20used%20to%20define%20alias.%20One%20is%20SQL%20Server%20Connection%20Manager%20shipped%20with%20SQL%20Server%202005.%20The%20other%20one%20is%20SQL%20Server%20Client%20Network%20Utility%20shipped%20with%20Windows%20and%20can%20be%20found%20%3CBR%20%2F%3E%20at%20%3CSTRONG%3E%20C%3AWINDOWSsystem32cliconfg.exe%20%3C%2FSTRONG%3E%20.%3C%2FP%3E%0A%20%20%3CP%3EAll%20connection%20alias%20information%20can%20be%20found%20under%20the%20following%20registry%3A%20%3CBR%20%2F%3E%20%3CSTRONG%3E%20HKEY_LOCAL_MACHINESOFTWAREMicrosoftMSSQLServerClientConnectTo%3C%2FSTRONG%3E%3C%2FP%3E%0A%20%20%3CP%3EBasically%2C%20alias%20can%20be%20used%20to%3A%20%3CBR%20%2F%3E%201)%20define%20a%20easy-to-remember%20(or%20use)%20name%20of%20a%20real%20SQL%20Server%20name.%20%3CBR%20%2F%3E%202)%20redirect%20SQL%20connection%20with%20SQL%20Server%20to%20another%20SQL%20Server%20instance%20on%20any%20machine.%20%3CBR%20%2F%3E%203)%20make%20connection%20to%20SQL%20Server%20using%20a%20specific%20protocol%20(e.g.%20TCP%2C%20Named%20Pipe%2C%20etc)%20with%20specific%20parameter%20(e.g.%20TCP%20port%2C%20pipe%20name).%3C%2FP%3E%0A%20%20%3CP%3ECase%203)%20is%20probably%20the%20most%20frequent%20usage.%20Because%20an%20alias%20always%20has%20a%20pre-defined%20protocol%2C%20it%20can%20speed%20up%20your%20connection.%20When%20making%20new%20connections%2C%20SQL%20server%20client%20try%20various%20protocols%20(Shared%20Memory%2C%20TCP%2C%20Named%20Pipe%2C%20VIA%2C%20etc)%20in%20a%20sequence.%20There%20is%20a%20pre-defined%20default%20protocols%20sequence%2C%20but%20user%20can%20change%20the%20sequence%20using%20the%20tools%20mentioned%20above.%20SQL%20Server%20Connection%20Manager%20is%20for%20SNAC%20and%20SQL%20Server%20Client%20Network%20Utility%20is%20for%20MDAC.%20If%20a%20connection%20fails%20with%20one%20protocol%2C%20we%20may%20try%20connection%20with%20another%20protocols%20if%20there%20are%20still%20time%20for%20login.%20So%2C%20if%20a%20user%20knows%20which%20protocol%20the%20server%20is%20listening%20on%20and%20they%20want%20to%20used%20it%2C%20he%20can%20define%20alias%20to%20use%20that%20protocol%20directly%2C%20saving%20the%20%3CBR%20%2F%3E%20time%20to%20try%20and%20fail%20with%20other%20protocols.%20Also%2C%20he%20can%20chose%20a%20protocol%20which%20has%20better%20performance%20on%20his%20system.%3C%2FP%3E%0A%20%20%3CP%3ETwo%20use%20cases%3A%20%3CBR%20%2F%3E%20a)%20A%20user%20can%20make%20connection%20to%20SQL%20Server%20named%20instance%20without%20having%20to%20specify%20the%20instance%20name%20in%20applications.%20For%20example%2C%20you%20have%20a%20named%20SQL%20Server%20instance%20NewInst%20on%20machine%20MyHost.%20You%20can%20define%20MyHostAlias%20to%20use%20Named%20Pipe%20protocol%20with%20the%20following%20Pipe%20name%20%3CA%20mce_href%3D%22file%3A%2F%2FMyHost%2Fpipe%2FMSSQL%24NewInst%2Fsql%2Fquery%22%20target%3D%22_blank%22%3E%20%5CMyHostpipeMSSQL%24NewInstsqlquery%20%3C%2FA%3E%20%2C%3C%2FP%3E%0A%20%20%3CP%3Eb)%20A%20user%20wants%20to%20use%20TCP%20protocol%20and%20has%20already%20configured%20the%20SQL%20Server%20to%20listen%20a%20specific%20port%20(e.g.%203456)%20rather%20than%20the%20default%20port%201433.%20Then%2C%20he%20can%20define%20a%20alias%20to%20do%20so.%20User%20can%20also%20pecify%20IP%20address%20directly%20in%20alias%2C%20thus%20saving%20some%20time%20on%20DNS%20query.%3C%2FP%3E%0A%20%20%3CP%3EIn%20the%20above%20cases%2C%20since%20the%20TCP%20port%20and%2For%20Pipe%20Name%20is%20known%20and%20have%20been%20saved%20with%20alias%2C%20user%20does%20not%20have%20to%20rely%20on%20SQL%20Browser%20to%20discovery%20the%20server%2C%20which%20saves%20time%20and%20exposes%20less%20security%20risk%20as%20well.%3C%2FP%3E%0A%20%20%3CP%3EAs%20you%20can%20see%2C%20alias%20has%20a%20lot%20of%26nbsp%3Bbenefits.%20However%2C%20if%20not%20used%20properly%2C%20you%20may%20see%20issues%20hard%20to%20trouble-shoot.%20For%20example%2C%20you%20defined%20an%20alias%20called%20MyHost%20and%20let%20it%20connect%20to%20a%20SQL%20Server%20on%20MyHost%20using%20TCP.%20Later%2C%20your%20DBA%20decides%20to%20turn%20off%20TCP%20and%20let%20the%20server%20only%20listen%20on%20NP%20or%20change%20TCP%20port%20number%2C%20you%20may%20not%20be%20able%20to%20connect%20to%20MyHost%20unless%20you%20remember%20an%20alias%20is%20defined%20and%20delete%2Fredefine%20the%20alias.%20It's%20usually%20very%20hard%20for%20a%20user%20to%20realize%20the%20alias%20is%20the%20root%20cause%20of%20the%20issue.%3C%2FP%3E%0A%20%20%3CP%3ESo%2C%20as%20a%20suggestion%2C%20you'd%20better%20always%20put%20some%20special%20words%20in%20your%20alias%20so%20that%20you%20know%20it's%20an%20alias%20at%20anytime.%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3EXinwei%20Hong%2C%20SQL%20Server%20Protocols%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3EDisclaimer%3A%20This%20posting%20is%20provided%20%22AS%20IS%22%20with%20no%20warranties%2C%20and%20confers%20no%20rights%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-383200%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20MSDN%20on%20Jan%2007%2C%202007%20SQL%20Server%20client%20stack%20has%20a%20facility%20to%20let%20user%20define%20connection%20aliases.%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-383200%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESQLServerProtocols%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft
First published on MSDN on Jan 07, 2007

SQL Server client stack has a facility to let user define connection aliases. Connection Alias can usually help user make connection eaiser, faster and with more convenience. However, if it's not used properly, it sometimes results in connectivity issues which might be difficult to isolate.

User can take advantage of connection alias in both MDAC and SNAC. The information is saved in registry. There are two tools can be used to define alias. One is SQL Server Connection Manager shipped with SQL Server 2005. The other one is SQL Server Client Network Utility shipped with Windows and can be found
at C:WINDOWSsystem32cliconfg.exe .

All connection alias information can be found under the following registry:
HKEY_LOCAL_MACHINESOFTWAREMicrosoftMSSQLServerClientConnectTo

Basically, alias can be used to:
1) define a easy-to-remember (or use) name of a real SQL Server name.
2) redirect SQL connection with SQL Server to another SQL Server instance on any machine.
3) make connection to SQL Server using a specific protocol (e.g. TCP, Named Pipe, etc) with specific parameter (e.g. TCP port, pipe name).

Case 3) is probably the most frequent usage. Because an alias always has a pre-defined protocol, it can speed up your connection. When making new connections, SQL server client try various protocols (Shared Memory, TCP, Named Pipe, VIA, etc) in a sequence. There is a pre-defined default protocols sequence, but user can change the sequence using the tools mentioned above. SQL Server Connection Manager is for SNAC and SQL Server Client Network Utility is for MDAC. If a connection fails with one protocol, we may try connection with another protocols if there are still time for login. So, if a user knows which protocol the server is listening on and they want to used it, he can define alias to use that protocol directly, saving the
time to try and fail with other protocols. Also, he can chose a protocol which has better performance on his system.

Two use cases:
a) A user can make connection to SQL Server named instance without having to specify the instance name in applications. For example, you have a named SQL Server instance NewInst on machine MyHost. You can define MyHostAlias to use Named Pipe protocol with the following Pipe name \MyHostpipeMSSQL$NewInstsqlquery ,

b) A user wants to use TCP protocol and has already configured the SQL Server to listen a specific port (e.g. 3456) rather than the default port 1433. Then, he can define a alias to do so. User can also pecify IP address directly in alias, thus saving some time on DNS query.

In the above cases, since the TCP port and/or Pipe Name is known and have been saved with alias, user does not have to rely on SQL Browser to discovery the server, which saves time and exposes less security risk as well.

As you can see, alias has a lot of benefits. However, if not used properly, you may see issues hard to trouble-shoot. For example, you defined an alias called MyHost and let it connect to a SQL Server on MyHost using TCP. Later, your DBA decides to turn off TCP and let the server only listen on NP or change TCP port number, you may not be able to connect to MyHost unless you remember an alias is defined and delete/redefine the alias. It's usually very hard for a user to realize the alias is the root cause of the issue.

So, as a suggestion, you'd better always put some special words in your alias so that you know it's an alias at anytime.

Xinwei Hong, SQL Server Protocols

Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights