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


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?

Important: This area is reserved for useful tips. Therefore, do not post any questions here. Instead, use our public forums to post questions.


Social Media

Powered by