Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2005 > SQL Server 2005
| Search | Today's Posts | Mark Forums Read
SQL Server 2005 General discussion of SQL Server *2005* version only.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 15th, 2006, 03:08 PM
Registered User
Join Date: Mar 2006
Location: Frederick, MD, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Scripting database objects in dependency order

We're building a new application on SQL 2005, requiring a new database and objects. I'm making frequent changes to the objects, often making a specific change to all of the tables. In SQL 2000 I would just script out the database, make my change, and apply the script (assuming that the tables are empty or can be easily refilled).
When I script out the objects in SQL 2005 I get an option to generate create or drop statements, but not both (if exists... drop table). More importantly, the objects aren't scripted in dependency order (i.e. the customer table must be created first but deleted last).

Am I missing something? Is there an option on the scripting wizard to give me the functionality like it was in SQL 2000? Is there anything else I can try, besides writing my own scripting app?

Thanks for listening!


Old March 15th, 2006, 10:20 PM
Registered User
Join Date: Apr 2005
Location: Shelbyville, KY, USA.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts

So there are two issues here...

1. How to generate if exists drop...create?
A. I am not sure how offhand just via Mgmt Studio to accomplish this exact requriement. What I can tell you is that using the Script Wizard (right-click on DB, Tasks, Generate Scripts), you get several options under the General Tab on the "Choose Scripting Options" step including "include if not exists". What this does is if not exists then create so its not exactly what you want aka a straight drop then create but its as close as I can find offhand just via the UIs.

2. How to script dependent DB objects in order?
A. While I am not aware of anyway to specify ordering, you can use the same Script Wizard I mentioned above with another General Script option/setting for dependant DB objects.

Hope this helps,

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multilingual Database Objects Muhammad Zeeshan SQL Server 2000 1 August 13th, 2007 02:56 AM
Scripting Database mike_remember SQL Server 2000 4 October 31st, 2006 10:27 AM
dependency files m002864 Crystal Reports 0 July 7th, 2004 02:56 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.