title: How can I script an MS SQL Server database with proper object ordering?
body: <p>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.</p>
  
  <p>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.</p>
  
  <p>Do you know how to script the database schema with the proper order of object creation?</p>