Friday, March 9, 2012

Generate SQL Script

Hello,

I want to generate a SQL Script of a SQL Server database. To do this, I
right-click the database name and choose the option All Tasks/Generate
SQL Script.

Than I get a text file with a script that generates all objects, but the
order in which the objects are generated is wrong. There are a lot of
views in the database and many views are based on other views. When I
try to execute the script on a different computer, I get a lot of error
messages, because the script tries to create views that are based on
other views that are not created yet.

Is there a way to generate a script that automatically 'knows' which
views to create first or do I have to manually look through all views
and find out myself the execute order? (I hope not, because it are
really a lot of views).

Greetings,
Chris

*** Sent via Developersdex http://www.developersdex.com ***Chris,

Quote:

Originally Posted by

I want to generate a SQL Script of a SQL Server database. To do this, I
right-click the database name and choose the option All Tasks/Generate
SQL Script.
>
Than I get a text file with a script that generates all objects, but the
order in which the objects are generated is wrong. There are a lot of
views in the database and many views are based on other views. When I
try to execute the script on a different computer, I get a lot of error
messages, because the script tries to create views that are based on
other views that are not created yet.
>
Is there a way to generate a script that automatically 'knows' which
views to create first or do I have to manually look through all views
and find out myself the execute order? (I hope not, because it are
really a lot of views).


Download yourself a copy of our database developer IDE called
"Database Workbench" at www.upscene.com
When extracting DDL, it shuffles the views around in the dependency
order.

--
Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com

No comments:

Post a Comment