HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlMinor

How do I force windows to use a specific version of SQLCMD?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
forcehowversionsqlcmdwindowsspecificuse

Problem

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?

Solution

Have you tried updating the PATH variable?

For Windows 10, do the following:

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

-
In the context menu, click Properties.

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

-
In the Advanced Tab, click on Environment Variables.

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

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

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

-
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



-
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.

Context

StackExchange Database Administrators Q#232639, answer score: 9

Revisions (0)

No revisions yet.