14

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.

CMCDragonkai
  • 6,222
  • 12
  • 56
  • 98
  • For reference: http://stackoverflow.com/questions/4944165/can-you-make-sqlcmd-immediately-run-each-statement-in-a-script-without-the-use-o – CMCDragonkai Jan 14 '17 at 12:19

1 Answers1

21

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

CMCDragonkai
  • 6,222
  • 12
  • 56
  • 98