In troubleshooting a SQL connectivity issue recently, I tried multiple tests in connecting to SQL to help troubleshoot the issue. In this post, let’s take a look at three lesser known ways to test SQL connectivity including ODBC, a UDL file, as well as the sqlcmd utility. These are lesser known ways than simply using SQL Server Management Studio, but each can prove beneficial when testing and troubleshooting.
Three ways to test SQL connectivity
One of the first lesser known ways to test connectivity is by using an ODBC connection. ย The ODBC connection utility is built into Windows and can be launched by typing inย odbcad32 at a run or search menu. ย Click theย System DNSย tab and then selectย Add.
Enter your Data source name and then the server you want to connect to.
Choose which type of authentication you wan to use – either Windows authentication which uses the currently signed on user, or SQL server authentication.
You can next through the following couple of screens. ย Finally select toย Test Data Source. ย You should see a “TEST COMPLETED SUCCESSFULLY” message displayed.
SQLCMD utility
The SQLCMD utility is also lesser known. ย This is installed with SQL Server Management Studio and is a command line way to both connect and execute SQL statements. ย Simply open a command prompt and execute theย sqlcmd /? to see the usage of the utility. ย As you can see, a few common parameters are the -S server, theย -U login id andย -P password. ย However, there are quite a few other parameters that can be used with the utility.
If you don’t specify theย -U andย -P for user and password, then Windows authentication is assumed and used. ย A typical connection test might look like this:
sqlcmd -S TESTSQLSERVER -U sa -P sapassword
UDL File
A UDL or Universal Data Link file can be used to easily test connectivity. ย Simply create a new file and rename it with aย .udl extension. ย Then double click the file.
Once you double click, theย Data Link Properties box opens. ย Here we can populate our connection information including theย server name,ย user name, andย password. ย If you select theย Use Windows NT Integrated security it will assume credentials of the logged in user. ย Once populated you can click theย Test Connection button to initiate the connectivity test.
When you click the Test Connection button, you should see the “Test connection succeeded” as the result.
Thoughts
Hopefully, theย Three lesser known ways to test SQL connectivity will shed light on additional ways to test connectivity to a SQL server either for verification or troubleshooting purposes. ย When troubleshooting a connectivity issue, the more tools and angles of testing, the better! ย Happy troubleshooting!