Command line package to upgrade target database
gbanister
Posts: 2
My goal is to create a couple batch jobs that will doo the following:
1) The first job needs to create a package like so,
sqlpackager /server1:"myserver" /database1:mysourcedatabase /location:".\DataPackages" /name:PackageName /makeexe
2) The second job needs to run the package that was created in the first job to "UPGRADE" a target database, not "CREATE" the target database. The job set that I'd like to run is like so,
PackageName.exe /server:myserver /database:mytargetdatabase /quiet
But my problem is that when running the second job it's trying to CREATE the target database and fails if it already exists. Is there a way to accomplish my goal?
Thanks,
Greg
1) The first job needs to create a package like so,
sqlpackager /server1:"myserver" /database1:mysourcedatabase /location:".\DataPackages" /name:PackageName /makeexe
2) The second job needs to run the package that was created in the first job to "UPGRADE" a target database, not "CREATE" the target database. The job set that I'd like to run is like so,
PackageName.exe /server:myserver /database:mytargetdatabase /quiet
But my problem is that when running the second job it's trying to CREATE the target database and fails if it already exists. Is there a way to accomplish my goal?
Thanks,
Greg
Greg Banister
Comments
SQL Packager creates an executable assembly that either upgrades or cretaes a new database. If you use the command-line version of SQL Packager, it assumes that if you specify two databases on the command line with the /database1 and /database2 arguments, and upgrade package will be created. If you specify only /database1 on its' own, then a creation package is produced.
SQL Packager creates static SQL commands that will be run on the database that you tell the SQL Package to run against; therefore, you need to tell SQL Packager the name of the second database: the one you're comparing against the first database in order to generate the synchronization script.
I hope that this clarifies things a bit.