how to run SQL scripts from a folder in a particular order?

  • Hello all,

    I want to run multiple SQL script files from a directory in a particular order. I want to read file names from a text file and run / execute SQL files accordingly.

    Can you please suggest, if i can achieve my goal using a batch file? if yes, any reference / example would be very helpful

    Thank you!

  • windows is pretty much ORDER By Filename

    whether from powershell, command window, or within a programming language and iterating through files,

    the data comes over as ordered by filename, unless you do something extra.

    So if you follow a naming convention for your files, they would be grabbed , and thus executed, in a specific order.

    I Typically do something like

    SQL001_ScriptPurpose.sql,

    SQL002_ScriptPurpose.sql

    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!

  • thank you!

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

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