We were experiencing problems connecting to a hidden SQL Server 2005 named instance. The only way we could successfully connect to the hidden named instance was through an alias on a client machine.

When I searched the Internet for a solution, I noticed that all the material I read said the connection strings had to be in the format ServerName\InstanceName,PortNumber (e.g., ProdServer\Reports,3334). This got me thinking. When this format is used, the connection string doesn't work with hidden named instances because the string is identifying the named instance. I wondered what would happen if the named instance wasn't part of the string, so I removed it. When I tried the revised connection string, which followed the format ServerName,PortNumber (e.g., ProdServer,3334), I was able to connect to the SQL Server 2005 named instance.

I've found that the shortened connection string also works with hidden SQL Server 2000 named instances, many tools (including Enterprise Manager), and ODBC connection strings. You can even apply the concept to Java Database Connectivity (JDBC) connection strings. For example, our JDBC driver uses a connection string that follows the format ServerName:InstanceName:PortNumber (e.g., ProdServer:Reports:3334).When I used only the server name and port number in the format ServerName:PortNumber (e.g., ProdServer:3334), I was able to connect to the hidden SQL Server 2005 named instance.

The shortened connection string works on any instance hosted on any server. I even made it a personal best practice to use the port number, even for the default port (1433), so I can better distinguish one instance from another. However, the shortened connection string only partially works with the dedicated administrator connection. So far, I've only been able to connect to an instance with the dedicated administrator connection though SQL Profiler and an ODBC connection string but not through SQL Server Management Studio (SSMS).
—Gilles Despaties, Senior Database Administrator, House of Commons of Canada

See Associated Figure

End of Article




You must log on before posting a comment.

If you don't have a username & password, please register now.

Reader Comments

Superb digging. I have never thought of omitting the instance name... Always applied an alias. Thanks very much. :O)

dspglobal

Article Rating 5 out of 5

Just one word of caution if you want to use this as I have learned after submitting the article: ensure that the port you are using for the (named) intance is static, not dynamic. SQL Server started on two of our instances with a different port because we have left them as dynamic. Gilles Despaties

Desperado

Article Rating 5 out of 5

 
 

ADS BY GOOGLE