Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I script an MS SQL Server database with proper object ordering?

Tags:

I'm trying to script an MS SQL Server 2005 database to a single file. So far I've tried using SQL Management Studio and the MS Database Publishing Wizard.

Both tools will script the database objects without a problem although neither tool is scripting objects in the right order of creation. For instance the script might script a view which requires a table that's not going to be created until later down the line.

Do you know how to script the database schema with the proper order of object creation?

like image 215
Ian Suttle Avatar asked Mar 17 '09 08:03

Ian Suttle


1 Answers

We use this to create the db scripts, i'd have to run it up again to ensure it creates objects dependants first... but i haven't had a problem yet. http://www.red-gate.com/products/SQL_Compare/index.htm

like image 66
GordonB Avatar answered Sep 22 '22 14:09

GordonB