Tag Archives: SQLCMD command

:ON ERROR [exit/ignore] SQLCMD Command

:ON ERROR [exit/ignore] This command instructs SQLCMD on how to handle errors during script execution. The following options are available: *      exit Exits the program with the appropriate error value *      ignore Ignores the error and continues execution. An error … Continue reading

Posted in Uncategorized | Tagged , , | Leave a comment

:PERFTRACE /STDERR/STDOUT SQLCMD Command

ERFTRACE <filename>/STDERR/STDOUT The ERFTRACE command redirects all performance information (see the discussion of the -p option) that by default goes to standard output.

Posted in Uncategorized | Tagged , , | Leave a comment

:OUT /STDERR/STDOUT SQLCMD Command

:OUT <filename>/STDERR/STDOUT This command redirects all query results output that by default gets sent to standard output.

Posted in Uncategorized | Tagged , | Leave a comment

:LISTVAR and :LIST SQLCMD Command

:LISTVAR and :LIST The LISTVAR command was mentioned earlier during the introduction of scripting variables. It lists currently defined variables and, as such, is handy in troubleshooting SQLCMD. There is a different command, LIST, which enables you to list contents … Continue reading

Posted in Uncategorized | Tagged , , , | Leave a comment

:SERVERLIST SQLCMD Command

:SERVERLIST This command corresponds to the command line option -L, listing all locally configured servers and the names of the servers broadcasting on the network. How does it help you to know the names of all servers when you are … Continue reading

Posted in Uncategorized | Tagged , , | Leave a comment

:r SQLCMD Command

:r <filename> This option enables the script writer or interactive user to read the contents of a specified script file and include it in the current execution session. The included file is processed in-place; in other words, every command encountered … Continue reading

Posted in Uncategorized | Tagged , | Leave a comment

:SETVAR [""] SQLCMD Command

:SETVAR <variable name> ["<variable value>"] The SETVAR option, already mentioned earlier during the discussion on scripting variables, enables you to set their values programmatically inside the script. One interesting aspect of the SETVAR command is that it is possible to … Continue reading

Posted in Uncategorized | Tagged | Leave a comment

[:]EXIT[(statement)] SQLCMD Command

[:]EXIT[(statement)] This function has three distinctly different formats. *      :EXIT supplied without parenthesis has the same affect as QUIT. *      :EXIT() first executes previously accumulated statements and only then exits the session. *      :EXIT(query) first executes previously accumulated statements, then … Continue reading

Posted in Uncategorized | Tagged , | Leave a comment

[:]QUIT SQLCMD Command

[:]QUIT This command immediately ends the current SQLCMD session without running any statements in the statement cache.

Posted in Uncategorized | Tagged , | Leave a comment

[:]!! SQLCMD Command

[:]!! <command> Typing !! allows the user to pass essentially any operating system command straight to the command line interpreter for direct execution and passes the output back to your display. Warning This is a very powerful option that can … Continue reading

Posted in Uncategorized | Tagged | Leave a comment