Wednesday, August 26, 2015

Testing connectivity to Microsoft SQL Server

Testing connectivity to Microsoft SQL Server without any tools installed

Often you'll find yourself logged into a web or application server and need to simply test that you can get to the SQL server you've unsuccessfully been trying to point your app at. Luckily there is a nifty trick built into Windows that allows you to save the day without having to install anything on your box – and it works on both client and server operating systems just as well.

Why would i ever need this?

Your app is having trouble connecting to SQL and you don't know what's wrong.
Is something wrong with your app?
Is it a network or firewall issue?
Is SQL even there…?

The "so easy it almost can't be true" solution

The guys at Microsoft have baked a SQL Connectivity tool right into Windows with the creation of Microsoft Universal Data Link files (*.UDL) – something designed for another purpose.
These were designed as a way to save SQL connection data for use in a whole range of applications and are available on pretty much every version of Windows since *eternity*.
They also provide an awesome way to test SQL Connectivity.
To make this work simply follow the bouncing ball:
Create a new file anywhere. For arguments sake create a new Text file on your desktop
image
Now rename that file and change it's file extension to TestDatabase.udl (take note of the file extension).
image
Select "Yes" when asked if you want to change the file extension.
This will give you a Data Link Editor that allows you to test the connection.
image
Pretty nifty in times of need!

No comments: