Connect to SQL server and execute a script

  • The client:

    Windows XP machine sp3

    The server:

    SQL 2005 server

    Problem:

    I need to create a scheduled task that would automatically execute on the client machine. The script (I am familiar with VB script or it can be simply a batch file) is to connect to the sql server first and then execute the select query. The output of the query will need to be saved to a csv file on the client machine. There is a "System DSN ODBC" connection setup in the client machine.

    I will give updates as I progress with this, but if you have ideas that can help me please post it.

  • you can try with powershell to extract data from SQL server.

    Here is some example.

    http://www.sqlservercentral.com/articles/powershell/65196/

  • I installed SQL server express on the XP box.

    Now I can execute this from the command prompt:

    sqlcmd -S SrvrName -Uusername -Ppassword -i C:\NWC\ExtLogNWCBldg.SQL -o C:\NWC\NWC_Data.csv

    I created a bacth file and scheduled it to execute the above command

    It works fine..

    Thanks

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply