Create exe file for n number of scripts

  • Hi All,

    Is there someone who can guide me for the following. I have hundreds of scripts to be executed each time against a database in different servers. I have now written a batch program now but that invloves lot of manual work too. Is there any tools that can take these files as input and generate me a exe to run against the target database.

    Cheers,
    Sugeshkumar Rajendran
    SQL Server MVP
    http://sugeshkr.blogspot.com

  • Don't know how to make the .exe, but if you have a list of servers, generate the call to the batch file with parameters, something like:

    SELECT 'MyBatFile.Bat ' + Servername

    FROM ListOfServers

    In the batch file, replace the server name with %1 (I think, it's been a while. See 'batch files, replaceable parameters in' in Windows Help. Save the output as a batch file, and run it.

    Alternatively, there is

    for %%variable in (set) do command [command-parameters]

    See FOR command in Windows Help. This allows you to do it in one batch.

  • I have no probs with the servername that i have already handled internally the issue is i have hundreds of scripts and now using a batch file to call them one by one it would be great if there is an tool to generate an exe which calls these sctips and fire against the target server.

    Cheers,
    Sugeshkumar Rajendran
    SQL Server MVP
    http://sugeshkr.blogspot.com

  • Sugesh getting a program to call them all is pretty easy...the problem is usually dependancy issues....you know, script 42 has to be run after some other specific scripts, something in script "CreateEntities" assumes something else already exists.

    unless you hav some way to determine the order, (ie a naming convention or a specified list), you'd run into trouble.

    what kind of assumptions can you make about the files automatically? that every script in the executable's folder ends in .SQL?

    that if you sort the names of the .SQL files, they are in the right order?

    what do you do if one of the scripts fail? is it a monster transaction, or can each script fail, and you just report script failures?

    I can throw you a vb6 or does exactly that,  but there's usually a lot of assumptions.

     

     

     

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

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

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