Reputation: 77
I've run into a problem about sqlcmd,
In the computer there is SSMS 2017 and I can use SQLCMD MODE in SSMS 2017, but I can't call sqlcmd in command prompt,
"'sqlcmd.exe' is not Recognized as an Internal or External Command, Operable Program or Batch File"
and i couldn't find the SQLCMD.EXE in the whole computer.
Since i can use SQLCMD MODE in SSMS, Is this means, there must be a sqlcmd.exe in the computer or not?
Thank you very much,
Upvotes: 5
Views: 25040
Reputation: 89141
Since i can use SQLCMD MODE in SSMS, Is this means, there must be a sqlcmd.exe in the computer or not?
Apparently not. I just tested by running
:!! powershell pause
in SQLCMD mode in SSMS and examining the process tree in Sysinternals Process Explorer:
It looks like SSMS is using PowerShell's Invoke-SqlCmd which is a seperate SQLCMD-compatible interpreter.
And SQLCMD is a seperate download since SSMS 18.0:
The following tools are no longer installed with SSMS:
OSQL.EXE
DReplay.exe
SQLdiag.exe
SSBDiagnose.exe
bcp.exe
sqlcmd.exe
Deprecated and removed features in 18.0
Upvotes: 8
Reputation: 11
My SQLCMD.EXE is located here:
C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\SQLCMD.EXE
You can download it here:
https://msdn.microsoft.com/de-de/library/ms162773.aspx
or
https://learn.microsoft.com/de-de/sql/tools/sqlcmd-utility?redirectedfrom=MSDN&view=sql-server-ver15
Upvotes: 1
Reputation: 1191
Do you try to add your SQL SERVER path to the PATH's environnement variable ?
To check it, run the folowing command on cmd :
Path
That'll print you the variable path. If there is not something like this :
;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\
;C:\Program Files\Microsoft SQL Server\140\Tools\Binn\
;C:\Program Files\Microsoft SQL Server\140\DTS\Binn\
You won't be able to execute sqlcmd.
SQLCMD is very useful for runing command on multiple instance for example in a batch file. Something cool with this command is also that you can pass in the argument '-i' a sql script to execute and in '-o' a file where output the result. Then, you'll be able to add variable argument with '-v' option.
That's a very powerfull feature and i don't know why everybdoy in the comment saying the opposite.
(sorry for my english, again, i'm french)
Upvotes: 2