How to include 'IF EXISTS' in Script Folder Generation?

Compares and synchronizes SQL Server databases, backups and scripts.

Moderators: JonathanWatts, Chris Auckland, David Atkinson, eddie davis, Anu Deshpande, Michelle Taylor, alice.easey, james.billings, chengvoon.tong

How to include 'IF EXISTS' in Script Folder Generation?

Postby yshteyman » Fri May 25, 2012 6:28 pm

I am trying to generate DDL using 'Create Scripts Folder' menu in Compare 10.2. My defaults shows checks for this option, but when I open separate script for each table in their folders it doesn't have this clause. My question is how to include it not only in deployment script but when I also generate table folder. If this is not possible how then I can create separate file for each table using synch wizard.

Thank you for your help.
Yulia
Yulia
yshteyman
 
Posts: 3
Joined: Fri May 25, 2012 6:24 pm

Postby Chris Auckland » Mon May 28, 2012 3:28 pm

Thanks for your post.

I'm afraid neither are possible with the current version.

The option to create a scripts folder is designed to be used to represent the complete schema of the database so it can be used as a data source. The scripts themselves aren't really designed to be deployed to other environments.

Likewise, the deployments scripts that can include 'IF EXISTS' are designed to be a single script and can't be broken down per object, unless you go through and create a project for each object. If you right-click on an object in the results grid, you can create a single deployment script for that object, but you can't get it do that for all objects in one go.

If you don't mind me asking, why do you need the existence checks for each script?

Feel free to log the suggestion on our uservoice site if you need it added to the tool.
Chris
Chris Auckland
 
Posts: 757
Joined: Tue Oct 24, 2006 2:12 pm
Location: Red Gate Software Ltd.

Postby David Atkinson » Mon May 28, 2012 10:26 pm

Yulia,

Can I ask why you want separate scripts for each object. How do you plan to use them?

David Atkinson
Product Manager
Red Gate
David Atkinson
 
Posts: 1124
Joined: Mon Dec 05, 2005 4:54 pm
Location: Twitter: @dtabase

Postby yshteyman » Tue May 29, 2012 2:54 pm

David,

We have install script shipped with our product. The install folder has script for each table and executed by controlled file listing all objects to install. In case an installation failed i want this to be re-runnable picking up from the objects it stopped. Let's say it installed all tables from A-C and failed on FK creation and exited. Next time I run install I want to skip all tables A-C and continue creating objects. I understand that i use script folder as not as intended.
Yulia
yshteyman
 
Posts: 3
Joined: Fri May 25, 2012 6:24 pm

Postby David Atkinson » Tue May 29, 2012 3:18 pm

Why not just package up the single deployment script in your install without the transaction wrapper option? This way if you run it and it fails half way, it will have progressed.

David
David Atkinson
 
Posts: 1124
Joined: Mon Dec 05, 2005 4:54 pm
Location: Twitter: @dtabase

Postby yshteyman » Tue May 29, 2012 3:46 pm

This is how we implemented now. But it is now easy to maintain large single script. For instance, if one table structure change I need to search one large script and it need to be very neatly modify versus re-creating automatically using a tool one file containing ONLy one table that was changed. This change proposed for improving maintenance and avoid possible edit errors. I don't think it hurts adding 'IF EXISTS'...Thanks.
Yulia
yshteyman
 
Posts: 3
Joined: Fri May 25, 2012 6:24 pm


Return to SQL Compare 10

Who is online

Users browsing this forum: Craigjw and 0 guests