Sql-server – sql command utility version is not working

command linesql server

I have two versions of SQL Command Utility installed on my system as mentioned below(I checked the versions by going to Control Pannel->ProgramsandFeatures).

  1. Microsoft Command Line Utilities 11 for SQL Server
  2. Microsoft Command Line Utilities 15 for SQL Server

However, when I go and check the version in command prompt by typing 'sqlcmd -?' it shows the Version 12.0.2000.8 NT.

Could anyone advise why the system is not taking the version 15 and how it will utilize version 15? Since I want to use '-G' switch but it is not available in the current installed version (12.0.2000.8 NT).

Best Answer

If you don't qualify the SQLCMD.EXE location at the command prompt, it will use the first one found in your search path. So you need to either fully qualify the path to the executable for the desired version or modify your search path so that the newer version directory is before the older one.