Sql-server – How to force windows to use a specific version of SQLCMD

command linesql serversqlcmd

I have several versions of SSMS installed on my machine. We have legacy servers running several versions of SQL Server, mainly 2008, 2012, and 2014. I use SQLCMD all the time, but it seems to default to the Version 10 version of the command.

C:\Program Files\Microsoft SQL Server\100\Tools\Binn

I need to use the one from the newer version for some of the new servers that don't have backwards compatibility enabled.

C:\Program Files\Microsoft SQL Server\110\Tools\Binn

What settings do I need to change so that I don't have to use the full path every time I want to use SQLCMD?

Best Answer

Have you tried updating the PATH variable?

For Windows 10, do the following:

  1. In the File Explorer, right-click on This PC.

  2. In the context menu, click Properties.

  3. In the System window, click the Advanced system settings page on the left-hand side.

  4. In the Advanced Tab, click on Environment Variables.

  5. In the System Variables window, highlight Path, and click Edit.

  6. In the Edit System Variables window, insert the cursor at the end of the Variable value field.

  7. If the last character is not a semi-colon (;), add one.

  8. After the final semi-colon, type the full path to the file you want to find.

    • In your case: C:\Program Files\Microsoft SQL Server\110\Tools\Binn
  9. Find the path with 100 in it, and then remove it.

Click OK in each open window.

Word of caution: After doing these steps, you will not be able to auto-find any other exe's that the system was able to find earlier in the older path you just removed.