Buy Me a Coffee

Buy Me a Coffee!

Thursday, January 12, 2017

Testing SQL Server connectivity using a UDL file

Ok, an old one, but a good one.  In Windows, if you have a database that you want to test the connection for, just create a text file on your desktop by right clicking on the desktop and choosing New/Text Document from the context menu:
Desktop context menu


Resulting Text File

Rename the file to have a UDL extension (if your desktop doesn't show the extensions, do the rename in a command prompt using the rename command):

When you double click the file, windows will open the Data Link Properties dialog which will let you test your connection information:
Data Link Properties dialog
One thing that trips people up regularly, you can only use the username and password fields to pass in SQL credentials.  They won't work for domain credentials since it is not using impersonation, just passing credentials.  If you need to test as another user, open a command prompt as that user and 'run' the UDL file as that user by just typing it's name (and path if you aren't in the same directory) in and hitting return.  That should launch it as that user and let you test using Windows NT Integrated security as them.

Have fun, and keep coding!