Home >> FAQs/Tutorials >> SQL Server FAQ

SQL Server FAQ - GO - Sending a Statement Batch from "sqlcmd"

By: FYIcenter.com

(Continued from previous topic...)

How To Use GO Command in "sqlcmd"?

"sqlcmd" is a command line client application to run Transact-SQL statements on a target SQL Server.

When "sqlcmd" is started and connected to a SQL Server, it will start a new batch and prompt you to enter the first statement of the batch. You can enter one or more statements in one or more lines to form a Transact-SQL statement batch.

To end a batch of statements and send it to the SQL Server for execution, you need to enter the GO command. The following "sqlcmd" tutorial session sends two batches to the SQL Server:

C:\>sqlcmd -S localhost\sqlexpress -U sa -P FYIcenter
1> SELECT getdate();
2> SELECT getdates();
3> SELECT getdate();
4> GO
Msg 195, Level 15, State 10, Line 2
'getdates' is not a recognized built-in function name.

1> SELECT getdate();
2> SELECT getdate();
3> SELECT getdate();
4> GO

-----------------------
2007-05-19 22:55:07.233
(1 rows affected)

-----------------------
2007-05-19 22:55:07.233
(1 rows affected)

-----------------------
2007-05-19 22:55:07.233
(1 rows affected)
1>QUIT
C:\

(Continued on next topic...)

  1. What Is SQL Language?
  2. What Is Transact-SQL Language?
  3. What Is a Transact-SQL Statement?
  4. How To Start and End Transact-SQL Statements?
  5. How To Enter Comments in Transact-SQL Statements?
  6. What Is a Transact-SQL Statement Batch?
  7. What Happens to a Statement Batch If There Is a Compilation Error?
  8. How To Use GO Command in "sqlcmd"?
  9. How To Create User Messages with PRINT Statements?
  10. How Many Categories of Data Types Used by SQL Server?
  11. What Are Exact Numeric Data Types?
  12. What Are Approximate Numeric Data Types?
  13. What Are Date and Time Data Types?
  14. What Are Character String Data Types?
  15. What Are Unicode Character String Data Types?
  16. What Are Binary String Data Types?
  17. What Are the Differences between CHAR and NCHAR?
  18. What Are the Differences between CHAR and VARCHAR?
  19. What Are the Differences between DECIMAL and FLOAT?

Related Articles:

More...


Other Tutorials/FAQs:

More...


Related Resources:

More...


Selected Jobs:

More...