create batch file in SSIS using sql

  • Hi Everyone,

    I want to use SSIS to create a batch file which will be made from a sql query and then I want to run this batch file.

    The batch file will basically consist of a shortcut to start a windows program and create another batch file.

    The sql is as follows:

    select 'ECHO START program location > 123.bat'

    I want to insert the text 'ECHO START program location > 123.bat' into a batch file called 'batchfile.bat' and then I want to exexute the batch file.

    What is the best way to do this??

    Thanks

  • I would likely do such a thing from a script task..

    However, I have a wider question, what is it that you want to accomplish in the end?

    Why do you want to create a cmd script in the first place? Why not run the items directly from SSIS?

    CEWII

  • Hi, thanks for your reply.

    I want to be able to schedule this ssis package to run everyday.

    The sql script will look at new records created in a table and then insert these into the batch file and then the batch file will be executed.

  • Abs-225476 (3/21/2012)


    Hi, thanks for your reply.

    I want to be able to schedule this ssis package to run everyday.

    The sql script will look at new records created in a table and then insert these into the batch file and then the batch file will be executed.

    What is the batch file doing? Adding data to a table? Executing EXEs? A bit more detail would be super. The more you give the better solution we can suggest.

    CEWII

  • My bad, basically the end result is to create a number of batch files which simply open an application with the customers details already entered, the batch file will be used as a link in a report allowing the user to go directly to this application without entering the customer id.

    I know this is long winded but can't figure out another workaround. I did try using a batch file with a parameter but I just couldn't get it to work.

    The data returned in the sql query will generate script for all the new customers batch files. This batch file when run will create batch files for all the new customers. So basically we have a batch file creating a set of batch files.

    I have done this manually and it all works fine, all I need to do is to automate it so that any new customers that are created on the database have a batch file for their record.

    The sql script will return data as follows:

    ECHO START program location customerid=1 > 1.bat

    ECHO START program location customerid=2 > 2.bat

    The script above will be saved in a batch file and when this is run it will create batch files 1.bat and 2.bat.

    What is the best way to do this?

  • While I question the whole methodology I would probably do this as a data-flow task.

    The source would read the table and format the data for the ending result.

    The destination would be a flat-file destination.

    Write the whole process in one step.

    CEWII

Viewing 6 posts - 1 through 5 (of 5 total)

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