Command Line

Packages and compresses schema and contents of SQL Server databases

Moderators: JonathanWatts, Chris Auckland, David Atkinson, david connell, Anu Deshpande, Michelle Taylor, james.billings, Marianne

Command Line

Postby tspeich » Tue May 04, 2010 5:47 pm

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. :?:
tspeich
 
Posts: 10
Joined: Tue May 04, 2010 5:40 pm

Postby tspeich » Tue May 04, 2010 8:50 pm

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:
tspeich
 
Posts: 10
Joined: Tue May 04, 2010 5:40 pm

Postby eddie davis » Thu May 06, 2010 3:30 pm

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
Technical Support Engineer
Red Gate Software Ltd
E-mail: support@red-gate.com
eddie davis
 
Posts: 942
Joined: Wed Jun 14, 2006 3:47 pm
Location: Red Gate Software

Postby tspeich » Thu May 06, 2010 3:57 pm

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.
tspeich
 
Posts: 10
Joined: Tue May 04, 2010 5:40 pm

Postby David Atkinson » Thu May 06, 2010 6:09 pm

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
 
Posts: 1124
Joined: Mon Dec 05, 2005 4:54 pm
Location: Twitter: @dtabase

Postby tspeich » Thu May 06, 2010 7:52 pm

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.
tspeich
 
Posts: 10
Joined: Tue May 04, 2010 5:40 pm


Return to SQL Packager 6

Who is online

Users browsing this forum: No registered users and 0 guests