USE <DATABASE> statement in compare scripts
USE <DATABASE> statement in compare scripts
Hello,
I'm currently looking into available tools to perform DDL and DML comparison from the command line for an automation project of database continuous delivery. So besides a tool running from the command line it also needs to be able to generate the necessary scripts.
After a day of playing around with both dbForge schema and data compare, everything is looking fine and especially given the price, they seem to be good candidates for this project.
Unfortunately I'm currently stuck with one challenge. As the comparison phase is only done once, in the beginning of the automation chain, the generated scripts need to be portable. Having a look at the resulting files they could do the job if I could get rid of the USE <DATABASE> related statements.I spent quiet some time both on the command line as in the GUI to find it but without any luck.
Is there somewhere a switch option to deactivate it? It will avoid the trouble in scripting a solution the strip this code after generation.
Thanks
Björn
I'm currently looking into available tools to perform DDL and DML comparison from the command line for an automation project of database continuous delivery. So besides a tool running from the command line it also needs to be able to generate the necessary scripts.
After a day of playing around with both dbForge schema and data compare, everything is looking fine and especially given the price, they seem to be good candidates for this project.
Unfortunately I'm currently stuck with one challenge. As the comparison phase is only done once, in the beginning of the automation chain, the generated scripts need to be portable. Having a look at the resulting files they could do the job if I could get rid of the USE <DATABASE> related statements.I spent quiet some time both on the command line as in the GUI to find it but without any luck.
Is there somewhere a switch option to deactivate it? It will avoid the trouble in scripting a solution the strip this code after generation.
Thanks
Björn
Re: USE <DATABASE> statement in compare scripts
Unfortunately, there is no such a possibility.
However, you can add a suggestion on our UserVoice forum where other users can vote for it http://devart.uservoice.com/forums/1770 ... sql-server
We collect and analyze the information from this forum in order to make a proper roadmap for future product releases.
However, you can add a suggestion on our UserVoice forum where other users can vote for it http://devart.uservoice.com/forums/1770 ... sql-server
We collect and analyze the information from this forum in order to make a proper roadmap for future product releases.
Re: USE <DATABASE> statement in compare scripts
In the Options menu I found a preferences list under "Generate Scripts", similar to what's used when scripting out of SSMS. If that is unchecked, I'm guessing the USE statement will not be written.
Re: USE <DATABASE> statement in compare scripts
Thx for your feedback.
I had discovered this one as well but I'm guessing this only applies when working with the GUI. For my automation project all needs to be command line based and there this option appears not to be present.
Cheers
Björn
I had discovered this one as well but I'm guessing this only applies when working with the GUI. For my automation project all needs to be command line based and there this option appears not to be present.
Cheers
Björn
Re: USE <DATABASE> statement in compare scripts
I have not tried yet, but I wonder if you create a generate scripts "project" file, is it possible to generate the scripts by referencing that file somehow, similar to the way a schema comparison can be accomplished by referencing an .scomp file.
Re: USE <DATABASE> statement in compare scripts
You can generate *.backup project file by clicking the 'Save Project' button in the Generate Scripts Wizard and then use the file in the command line interface:
Code: Select all
C:\Program Files\Devart\dbForge Schema Compare for SQL Server>schemacompare.com /script /connection:"Data Source=DBMSSQL\MSSQL2012;Integrated Security=False;User ID=sa" /projectfile:"D:\Scripts\AdventureWorks.backup"
Re: USE <DATABASE> statement in compare scripts
Not bad. But still not 100% command line compliant because with this solution we are still bound to the configuration inside the backup file.
So every change should be made through the gui. Then create a new backup file and make sure to deploy it correctly to the CI chain. As you can see this is creating a lot of extra overhead not to mention the increase of error margin. In a small environment this might be a valid workaround but in my current scope this option is not feasible.
Besides controlling the option directly from the command line (like Regdate, Idera, ... offer
), I see no other solution than parsing the resulting sql script and remove the obsolete statements.
But still open to other suggestions.
Cheers
Björn
So every change should be made through the gui. Then create a new backup file and make sure to deploy it correctly to the CI chain. As you can see this is creating a lot of extra overhead not to mention the increase of error margin. In a small environment this might be a valid workaround but in my current scope this option is not feasible.
Besides controlling the option directly from the command line (like Regdate, Idera, ... offer

But still open to other suggestions.
Cheers
Björn
Re: USE <DATABASE> statement in compare scripts
Thank you for the reply.
We will try implementing this in the next product version.
We will try implementing this in the next product version.