USE <DATABASE> statement in compare scripts

Discussion of open issues, suggestions and bugs regarding database management and development tools for SQL Server
Post Reply
bthijs
Posts: 3
Joined: Tue 24 Nov 2015 09:32

USE <DATABASE> statement in compare scripts

Post by bthijs » Tue 24 Nov 2015 15:55

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

alexa

Re: USE <DATABASE> statement in compare scripts

Post by alexa » Tue 24 Nov 2015 17:03

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.

mango333
Posts: 40
Joined: Thu 14 May 2015 19:23

Re: USE <DATABASE> statement in compare scripts

Post by mango333 » Wed 09 Dec 2015 16:05

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.

bthijs
Posts: 3
Joined: Tue 24 Nov 2015 09:32

Re: USE <DATABASE> statement in compare scripts

Post by bthijs » Wed 09 Dec 2015 16:19

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

mango333
Posts: 40
Joined: Thu 14 May 2015 19:23

Re: USE <DATABASE> statement in compare scripts

Post by mango333 » Wed 09 Dec 2015 17:09

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.

alexa

Re: USE <DATABASE> statement in compare scripts

Post by alexa » Thu 10 Dec 2015 08:31

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"

bthijs
Posts: 3
Joined: Tue 24 Nov 2015 09:32

Re: USE <DATABASE> statement in compare scripts

Post by bthijs » Thu 10 Dec 2015 08:53

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 :D ), 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

alexa

Re: USE <DATABASE> statement in compare scripts

Post by alexa » Thu 10 Dec 2015 14:36

Thank you for the reply.

We will try implementing this in the next product version.

Post Reply