0% found this document useful (0 votes)
191 views2 pages

SQLCMD

AnalogX SQLCMD allows users to execute SQL queries from the command line against ODBC data sources. It provides options to specify a username, password, database, log file, and SQL command. The utility returns 0 for success and 1 for failure, making it easy to run SQL queries from batch files.

Uploaded by

jesim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
191 views2 pages

SQLCMD

AnalogX SQLCMD allows users to execute SQL queries from the command line against ODBC data sources. It provides options to specify a username, password, database, log file, and SQL command. The utility returns 0 for success and 1 for failure, making it easy to run SQL queries from batch files.

Uploaded by

jesim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

THE HANDY DANDY ANALOGX SQLCMD

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

AnalogX SQLCMD allows you to quickly and easily run SQL queries against ODBC
data sources. Basically, it's a simple portable way to execute SQL commands
from batch files, etc.

SQLCMD is like most commandline utilities out there; from the command prompt
you can type the name by itself to get a list of options:

F:\tools\sqlcmd> sqlcmd

AnalogX SQLCMD version 1.00 (Release)


The latest version can always be found at http://www.analogx.com/

Usage: SQLCMD [options]


Options: /USER [name] Username to login as
/PASS [password] Password for username
/DB [database] Name of ODBC connection to use
/LOG [filename] Log results to file
/APPEND Append results to file
/SILENT Do not decode results
/COMMAND [cmd] SQL command to execute

Here's a brief description of each option:

USER This is the username to login to the database with. This field
is optional and will try to log in using a NULL account when it
is not supplied.
PASS Password for username specified above.
DB ODBC Database to connect to.
LOG Specify the filename to log to. Useful for debugging or keeping
track of operations performed. While not a log in the normal
sense, it outputs all information pertaining to commands run.
APPEND Instead of overwriting the existing log file, it will append
onto it.
SILENT Suppresses all text output.
COMMAND SQL query to perform

It's all pretty straight-forward (to my thinking, at least). Here's a couple


of examples:

sqlcmd /log "C:\Logs\sqlcmd.log" /append /db "Website" /command "select * from


[users]"

or:

sqlcmd /user Jimmy /pass Password /db "Website" /command "update [users] set
Downloads=1"

also, if you execute it like so:

sqlcmd /user Han /db "Website"

without the /COMMAND then it will go into it's "interactive" mode, where you
can just enter in SQL queries. Once in this mode, simply type 'QUIT' and it
will exit.

If the program thinks it has successfully executed the command, it will return
0, otherwise it will return 1 (these are normally the defaults for success
and failure for commandline programs), so it should be easy to include SQL
commands into batch files.

For more info, and some MP3 music, make sure to check out our website at:

http://www.analogx.com/

You might also like