views:

35

answers:

1

When we script all Sql Server Database objects from Management Studio by right clicking on the database, and go to tasks and select "generate scripts", will the generated scripts be in order???

A: 

If you are talking in terms of dependencies, I can confirm that it does work as you would expect. Objects that have dependencies are scripted after their dependents

rip
Yeah! I agree with you.
whizzing_hornet
I found recently something on Pinal Dev blog and some people were complaining about only views not scripted in right order.
whizzing_hornet
In the past I’ve run into ordering problems when I scripted the table, views, ... separately (i.e. ran the script generator once for tables, and again for views, ...). However, when I script the objects in one process the ordering is fine.
rip
@rip: When you script all at once and you found the order right, then I would assume that any of the table structures were never changed. If some of them were changed and you did not refresh the views, then when you script everything out, your order will not be right. So, one needs to refresh the views first before scripting out all objects and everything will be in order.
whizzing_hornet