Run all .sql files (scripts) in project (SQL Server 2005 SP2)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • downwitch

    Run all .sql files (scripts) in project (SQL Server 2005 SP2)

    Hello,

    I've run as many keyword combinations searching for this as I can
    think of, but cannot find a simple answer.

    The situation: I have a database that is mid-conversion/redevelopment.
    I frequently rebuild my dev copy from the production version, which
    requires a bunch of DDL script, and then adding in all the stored
    procedures necessary to the new version only. Each sp may have changed
    since the last time it was run, so I can't exactly keep them all
    concatenated in a single file or anything like that.

    So the only way I can see to execute each and every one of these saved
    script files is to open it up in SSMS and hit F5 for execute. This is
    a silly waste of time, it seems to me, and hardly foolproof. Is there
    not some simple way to run every script in a project? What purpose
    does a project serve, otherwise?

    (Worth mentioning that the tool I found here
    http://www.codeproject.com/useritems...riptRunner.asp does not
    seem to work.)

    Thanks in advance.

  • Erland Sommarskog

    #2
    Re: Run all .sql files (scripts) in project (SQL Server 2005 SP2)

    downwitch (downwitch@gmai l.com) writes:
    I've run as many keyword combinations searching for this as I can
    think of, but cannot find a simple answer.
    >
    The situation: I have a database that is mid-conversion/redevelopment.
    I frequently rebuild my dev copy from the production version, which
    requires a bunch of DDL script, and then adding in all the stored
    procedures necessary to the new version only. Each sp may have changed
    since the last time it was run, so I can't exactly keep them all
    concatenated in a single file or anything like that.
    >
    So the only way I can see to execute each and every one of these saved
    script files is to open it up in SSMS and hit F5 for execute. This is
    a silly waste of time, it seems to me, and hardly foolproof. Is there
    not some simple way to run every script in a project? What purpose
    does a project serve, otherwise?
    SQL code should be kept under source control, just likely any other code,
    and deployment should be done from the version-control system.

    Having said that, there are a couple of options you consider. One is
    SQL Compare from Red Gate, although they currently have no direct support
    for Source Control. The latest version supports comparing a database to
    folder structure on disk, though.

    A much more simple-minded way is to get a list of all stored procedures
    you need to load. Put that in a text file, and then use a text editor
    with good find-replace capabilities to transform the list to a BAT
    file that runs SQLCMD to load the files. Just make sure that you run
    SQLCMD with the -I option, so that you run with QUOTED_IDENTIFI ER ON.


    --
    Erland Sommarskog, SQL Server MVP, esquel@sommarsk og.se

    Books Online for SQL Server 2005 at

    Books Online for SQL Server 2000 at

    Comment

    • xman

      #3
      Re: Run all .sql files (scripts) in project (SQL Server 2005 SP2)

      On Aug 22, 5:52 pm, Erland Sommarskog <esq...@sommars kog.sewrote:
      downwitch (downwi...@gmai l.com) writes:
      I've run as many keyword combinations searching for this as I can
      think of, but cannot find a simple answer.
      >
      The situation: I have a database that is mid-conversion/redevelopment.
      I frequently rebuild my dev copy from the production version, which
      requires a bunch of DDL script, and then adding in all the stored
      procedures necessary to the new version only. Each sp may have changed
      since the last time it was run, so I can't exactly keep them all
      concatenated in a single file or anything like that.
      >
      So the only way I can see to execute each and every one of these saved
      script files is to open it up in SSMS and hit F5 for execute. This is
      a silly waste of time, it seems to me, and hardly foolproof. Is there
      not some simple way to run every script in a project? What purpose
      does a project serve, otherwise?
      >
      SQLcode should be kept under source control, just likely any other code,
      and deployment should be done from the version-control system.
      >
      Having said that, there are a couple of options you consider. One isSQLComparefro m Red Gate, although they currently have no direct support
      for Source Control. The latest version supports comparing a database to
      folder structure on disk, though.
      >
      A much more simple-minded way is to get a list of all stored procedures
      you need to load. Put that in a text file, and then use a text editor
      with good find-replace capabilities to transform the list to a BAT
      file that runs SQLCMD to load the files. Just make sure that you run
      SQLCMD with the -I option, so that you run with QUOTED_IDENTIFI ER ON.
      >
      --
      Erland Sommarskog,SQLS erverMVP, esq...@sommarsk og.se
      >
      Books Online forSQLServer200 5 athttp://www.microsoft.c om/technet/prodtechnol/sql/2005/downloads/books...
      Books Online forSQLServer200 0 athttp://www.microsoft.c om/sql/prodinfo/previousversion s/books.mspx- Hide quoted text -
      >
      - Show quoted text -
      downwitch - we have a new product that will be released in the next
      few days, xSQL Builder that allows you to create a database deployment
      package which between other things allows you to specify a folder
      where you can have all the scripts you want to run before the database
      synchronization takes place and also you can specify a folder where
      all your post synchronization scripts are. The application will run
      all those scripts on one big transaction and log everything.

      Email us at our support address @ xsqlsoftware.co m and we will send
      you the pre-release build so you can give it a try.

      Thanks,
      JC
      xSQL Software
      xSQL Software provides tools and API for comparing and synchronizing data and schema of SQL Server and Oracle databases, searching database schemas, automating the deployment of schema changes and the execution of SQL scripts, generating RSS feeds from SQL Server queries and SQL Server jobs.




      Comment

      • xman

        #4
        Re: Run all .sql files (scripts) in project (SQL Server 2005 SP2)

        On Aug 22, 11:24 am, downwitch <downwi...@gmai l.comwrote:
        Hello,
        >
        I've run as many keyword combinations searching for this as I can
        think of, but cannot find a simple answer.
        >
        The situation: I have a database that is mid-conversion/redevelopment.
        I frequently rebuild my dev copy from the production version, which
        requires a bunch of DDL script, and then adding in all the stored
        procedures necessary to the new version only. Each sp may have changed
        since the last time it was run, so I can't exactly keep them all
        concatenated in a single file or anything like that.
        >
        So the only way I can see to execute each and every one of these saved
        script files is to open it up in SSMS and hit F5 for execute. This is
        a silly waste of time, it seems to me, and hardly foolproof. Is there
        not some simple way to run every script in a project? What purpose
        does a project serve, otherwise?
        >
        (Worth mentioning that the tool I found herehttp://www.codeproject .com/useritems/SSMSScriptRunne r.aspdoes not
        seem to work.)
        >
        Thanks in advance.
        Hello downwitch,

        xSQL Software has just released a free utility, xSQL Script Executor,
        that allows you to run multiple T-SQL scripts at once - you can choose
        individual scripts or whole folders and run them all. You can choose
        to wrap all scripts in one big transaction or not, you can call it
        from the command line etc. Check it out at:


        Thanks,
        JC
        xSQL Software
        xSQL Software provides tools and API for comparing and synchronizing data and schema of SQL Server and Oracle databases, searching database schemas, automating the deployment of schema changes and the execution of SQL scripts, generating RSS feeds from SQL Server queries and SQL Server jobs.



        Comment

        Working...