I just freshly installed SQL Server Express 2014 via Chocolatey. The service is currently running.
When I run this inside my CMD or Powershell:
> sqlcmd -e -S .\SQLEXPRESS
1> sp_databases;
2>
I get no output, it just goes to the next prompt line.
However when I use this style, I do get output:
> sqlcmd -e -S .\SQLEXPRESS -Q "sp_databases;"
sp_databases;
DATABASE_NAME DATABASE_SIZE REMARKS
-------------------------------------------------------------------------------------------------------------------------------- ------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
master 7808 NULL
model 5312 NULL
msdb 37632 NULL
tempdb 2560 NULL
What could be the reason for this? I have no special configuration for the CMD or Powershell except some colour changes of the console.
You could try to execute sqlcmd.exe -? in a process in your C# app - if it works, then SQLCMD is present - if not, it'll tell you something like "file not found" or "command invalid" or something ....
To turn SQLCMD scripting on by default, on the Tools menu select Options, expand Query Execution, and SQL Server, click the General page, and then check the By default open new queries in SQLCMD Mode box.
Typical path for the SQLCMD.exe utility is: MSSQL 2008: C:\Program Files\Microsoft SQL Server\100\Tools\Binn\ MSSQL 2012: C:\Program Files\Microsoft SQL Server\110\Tools\Binn\ MSSQL 2014: C:\Program Files\Microsoft SQL Server\120\Tools\Binn\
Turns out I just needed to run GO
at the end of each command. Silly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With