Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I remember correctly, last time Microsoft Sqlcmd require each command to end with ';' and hit Enter key to execute the command.

However, currently, we need to type the GO each time to execute the command.

So, are there other alternative such that when we hit Enter key after ending the command with ';', it will Execute the command?

share|improve this question
Hitting Enter after ; is mysql interactive query tool. – Remus Rusanu Aug 28 '12 at 11:10
@RemusRusanu: actually nearly all query tools do it that way (Oracle, Postgres, Firebird, HSQLDB, ...). – a_horse_with_no_name Aug 28 '12 at 13:32
(Just a guess.) The semicolon is a statement delimiter in T-SQL. Previously it was completely optional because it was impossible to write an ambiguously interpreted batch (aka multi-statement query) that had no statement delimiters. Based on that, the semicolon was probably chosen as a batch delimiter in sqlcmd. However, since SQL Server 2005, new features have begun to appear in T-SQL that enable you to write an ambiguous batch if you don't delimit the statements. So, to avoid the ambiguity interpreting the function of ;, the need for a distinct batch delimiter must have arisen. – Andriy M Aug 28 '12 at 21:45
up vote 6 down vote accepted

No, you need to type a batch separator. The default is GO. However, you can change that by using the -c switch.

For example:

C:\>sqlcmd -SServername -cFOO

1> select @@version

hit enter

2> FOO

hit enter

This will run.

Can't get rid of the intermediate enter for you. Sorry.

share|improve this answer

GO is the batch terminator. Without it sqlcmd doesn't know to send the batch to the server for execution.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.