What is sqlcmd utility
The sqlcmd utility lets you enter Transact-SQL statements, system procedures, and script files at the command prompt, in Query Editor in SQLCMD mode, in a Windows script file or in an operating system (Cmd.exe) job step of a SQL Server Agent job. This utility uses ODBC to execute Transact-SQL batches.
SQL Server Management Studio uses the Microsoft .NET Framework SqlClient for execution in regular and SQLCMD mode in Query Editor. When sqlcmd is run from the command line, sqlcmd uses the ODBC driver. Because different default options may apply, you might see different behavior when you execute the same query in SQL Server Management Studio in SQLCMD Mode and in the sqlcmd utility.
Currently, sqlcmd does not require a space between the command line option and the value. However, in a future release, a space may be required between the command line option and the value.
Here is the syntax for the sqlcmd command listed with its arguments (parameters)
-A (dedicated administrator connection)
-b (terminate batch job if there is an error)
-C (trust the server certificate)
-e (echo input)
-E (use trusted connection)
-f codepage | i:codepage[,o:codepage] | o:codepage[,i:codepage]
-I (enable quoted identifiers)
-k[1 | 2] (remove or replace control characters)
-K application_intent -l login_timeout
-L[c] (list servers, optional clean output)
-N (encrypt connection)
-p (print statistics, optional colon format)
-q "cmdline query"
-Q "cmdline query" (and exit)
-r[0 | 1] (msgs to stderr)
-R (use client regional settings)
-u (unicode output file)
-v var = "value"
-W (remove trailing spaces)
-x (disable variable substitution)
-X (disable commands, startup script, environment variables and optional exit)
-Z new_password (and exit)
Remember that the option -? displays the syntax summary of sqlcmd options.
Options do not have to be used in the order shown in the syntax section.
When multiple results are returned, sqlcmd prints a blank line between each result set in a batch. In addition, the "<x> rows affected" message does not appear when it does not apply to the statement executed.
To use sqlcmd interactively, type sqlcmd at the command prompt with any one or more of the options described earlier in this topic. For more information, see Use the sqlcmd Utility
Note: The options -L, -Q, -Z or -i cause sqlcmd to exit after execution.
The total length of the sqlcmd command line in the command environment (Cmd.exe), including all arguments and expanded variables, is that which is determined by the operating system for Cmd.exe.
The usage of the sqlcmd can be read on Microsoft site: http://msdn.microsoft.com/en-us/library/ms180944.aspx