Revolving around the core of technology
Document ID: | 822 |
---|---|
Subject: | Using command line arguments to run SQL queries |
Creation date: | 7/29/09 4:58 PM |
Last modified on: | 9/16/13 5:02 PM |
WinSQL allows you to run SQL queries passed from a command line. You can either run saved SQL queries in a plain text file or run export routines saved as a WinSQL export template.
The following example shows how to run SQL scripts saved in a text file using WinSQL.
WinSQL -dYourDSN -uYourUserID -pYourPwd "-qc:\scripts\myScripts.sql" -a -oc:\output.txt
The following example runs queries stored in c:\scripts\myScripts.sql file using "YourDNS" as the data source, "YourUserID" as the user id, and "YourPwd" as your password. The "-a" option tells WinSQL to exit once the queries are completed. The "-oc:\output.txt" argument tells WinSQL to write any error messages to output.txt file.
Common mistakes
WinSQL c:\scripts\myScripts.sql
WinSQL -qc:\Scripts.sql -dYourDSNWinSQL will prompt you for a user id and password. This defeats the purpose of running queries in an unattended manner.
Do you have a helpful tip related to this document that you'd like to share with other users?