WinSQL » Knowledge base

Document information

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


Details


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

  • Often users simply type the following at the command line
    WinSQL c:\scripts\myScripts.sql

    The above example will open the scripts in the editor window but won't run it automatically.
  • If you only specify the DNS and file name, for example
    WinSQL -qc:\Scripts.sql -dYourDSN
    WinSQL will prompt you for a user id and password. This defeats the purpose of running queries in an unattended manner.





Add a comment to this document

Do you have a helpful tip related to this document that you'd like to share with other users? Please add it below. Your name and tip will appear at the end of the document text.
Your name:
Your email:
Hide my email address
Verification code:
Enter the verification code you see above more submitting your tip
Tip:Please limit tips to 1000 characters

Navigation

Social Media

Powered by 10MinutesWeb.com