Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sqlcmd.exe does not show any interactive output on the console (CMD and Powershell)

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.

like image 837
CMCDragonkai Avatar asked Jan 14 '17 12:01

CMCDragonkai


People also ask

How can I tell if SQLCMD is working?

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

How do I enable SQLCMD?

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.

Where can I find SQLCMD exe?

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\


1 Answers

Turns out I just needed to run GO at the end of each command. Silly.

like image 142
CMCDragonkai Avatar answered Oct 26 '22 03:10

CMCDragonkai