Problem solve Get help with specific problems with your technologies, process and projects.

Troubleshooting slow connections to SQL Server

If your attempts to connect to a SQL Server 7.0 or SQL Server 2000 take an extreme amount of time, try this workaround.

This tip was submitted to the searchWin2000 Tip Exchange by member Tim Fenner. Let other users know how useful it is by rating the tip below.

We had upgrade our Microsoft Data Access Components (MDAC) to version 2.6 on every PC/server, and each attempt to connect to a SQL Server 7.0 or SQL Server 2000 database using an IP address (rather than the server name) took an extreme amount of time and eventually timed out. After troubleshooting for a day, (which included attempting to roll back to the prior version of the MDAC), we came across Microsoft Q-article: Q300420.

In certain reported cases, a "Timeout expired" error is reported to the client application and the connection attempt fails or is extremely slow in its access times.

Be aware that if you are using a server alias which maps to a TCP/IP address, this problem can still occur.

This problem does not occur with MDAC 2.5 or 2.1 installed.

The MDAC 2.6 version of the SQL Server Network Library, Dbnetlib.dll, attempts to determine the host name of the IP address using a REVERSE lookup in DNS. If the client computer has a slow Domain Naming Service (DNS) server, or no DNS server, and the local HOSTS or LMHOSTS file on the computer does not contain the host name for the IP address of the SQL Server, the reverse lookup will time out after five seconds and/or your access to your databases will be extremely slow.

Note that this is an internal timeout inside of the SQL Server driver code only, and it may or may not generate a timeout error in the client application. The connection attempt can succeed, but every new connection made by the application will encounter the same five-second delay causing an overload of the database.

To resolve this problem, obtain the latest service pack for Microsoft SQL Server 2000. At time of this article, it would be service pack 2.

Q290211 INF: How to Obtain the Latest SQL Server 2000 Service Pack

To work around this problem, either provide some reliable means for performing a reverse lookup of the SQL Server server's IP address (set up a reverse lookup zone on your DNS server), use the SQL Server machine name instead of the IP address (which sometimes does not always work on some networks), or apply this hotfix.

Use the HOSTS file or LMHOSTS, put the TCP/IP address of the SQL Server server at the start of the line followed by a few spaces followed by the machine name of the SQL Server server. For example: myservername 
The HOSTS or LMHOSTS file belongs in the System32DriversEtc directory for client computers running Microsoft Windows NT and Microsoft Windows 2000, or in the Windows directory for clients running Microsoft Windows ME, Microsoft Windows 98, or Microsoft Windows 95.

We first tried using the hosts file on a single PC and added each SQL server into it. It corrected everything! Microsoft says in the article that service pack 2 fixes the issue, but it did not for us.

Dig Deeper on Enterprise infrastructure management