-1

Looked everywhere... to no avail.

I am trying to do a basic select using SQLCMD from the command line:

sqlcmd -S myServer -d myDB -E

So far so good.

select * from myTable

Nothing, just goes to the next line. Shouldn't it display a table with values ? Or at least "n row(s) returned" ?

I also tried the -o param: it creates an empty file.

AnalogKid17
  • 93
  • 1
  • 2
  • 9
  • Without the -Q or -q parameters, SQLCMD and OSQL launch a command-line editor. You will then need to enter the lines of queries, and then a GO on the final line to execute the batch. – Dan Guzman Oct 13 '14 at 17:12
  • Down-voter: how about you make your action constructive and explain what I did wrong? – AnalogKid17 Oct 13 '14 at 17:42

1 Answers1

2

When you use the SQLCMD tool in interactive mode statements that you enter are sent to the server when you use the keyword GO.

GO signals both the end of a batch and the execution of any cached Transact-SQL statements. When specifying a value for count, the cached statements will be executed count times, as a single batch.

See Use the sqlcmd Utility specifically the section titled Running Transact-SQL Statements Interactively by Using sqlcmd

So in your case:

select * from myTable enter

GOenter

jpw
  • 44,361
  • 6
  • 66
  • 86