Command Line

tspeichtspeich Posts: 14 Bronze 2
I am trying to package a script from the command line as part of an automated build process. I have created a project in Packager, that when run from the GUI works just fine and the result is a exe that will create a new database when run. When I run this same project from the command line via a cmd file, Packager still creates the package, but the resulting exe will only update an existing database. I only have 1 project created for packager, so I'm not mistakingly running the wrong one. :?:

Comments

  • tspeichtspeich Posts: 14 Bronze 2
    I have found a work around at least.
    The exe that is created as a result of running my project through SQL Packager, can be called from the command line with the switch /makedatabase. This will allow me to specify either to create or update no matter what the exe lets me do through the GUI. This still seems strange to me that the same project can have 2 different outcomes depending on where packager is called from. Maybe someone from Red Gate can give an explanation at their leisure. Until then I have my workaround. :lol:
  • Eddie DEddie D Posts: 1,802 Rose Gold 5
    Thank you for your post into the forum.

    I believe that you have answered your own question.

    Once you have your executable package created by SQL Packager, when the package is run you can either upgrade an existing database or create a new database.

    When you run the executable that SQL Packager has created it will bring a GUI and you specify the required options to make a new database or upgrade an existing database.

    Running the same excutable with no options from the command line will also open the same GUI for the user to specify the options which include upgrading an existing database or making a new database.

    If you run the executable from the command line and specify the server and database using the /server and /database switches the command line defaults to upgrading the database specified in the /database switch. To create a new database you need to use the /makedatabase switch and a new database will be created using the name specified by the /database switch.

    I hope the above answers your question.

    Many Thanks
    Eddie
    Eddie Davis
    Senior Product Support Engineer
    Redgate Software Ltd
    Email: support@red-gate.com
  • tspeichtspeich Posts: 14 Bronze 2
    The exe that is created(when packager is run from cmd) will not create a new database, unless I run it from the command Line. The desired result, would be an exe that is packaged by calling packager from the command line, and will create a new database without having to be run from the command line. When I open the exe's GUI there is no option for create or upgrade, upgrade is the only option available. The exe that is created when I run packager from the GUI does have the option of upgrading or creating. The exe that is created by sql packager, is not the same exe depending on where I called packager from.
  • David AtkinsonDavid Atkinson Posts: 1,457 Rose Gold 2
    I haven't tried this myself, but it might be possible to go through the Packager wizard and save the script, rather than creating the executable. You could edit this and add the CREATE DATABASE statement at the top. Run through the wizard again and package up the script you've modified.

    Is it a viable workaround?

    I agree that there are definite improvements we could make around creating databases whilst packaging, and we'll consider this in a future release.

    David Atkinson
    Red Gate Software
    David Atkinson
    Product Manager
    Redgate Software
  • tspeichtspeich Posts: 14 Bronze 2
    The projcect that I run in SQLPackager is a script created by SQLCompare after comparing a scripts folder of objects(all create scripts) against an empty database. Therefore what I'm packaging is already a big create script.

    I did just try to add a create db script that I use when testing the sync script that I get from SQLCompare. I still only get the option to upgrade, but I am able to choose the master table as my table to update and everything runs as I would like. :o

    It wasn't the end of the world or anything, but is always nice to be able to get what you want.

    Thanks for all your time David.
Sign In or Register to comment.