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
2010-01-12 16:46:45
Yeah! I agree with you.
whizzing_hornet
2010-01-12 16:49:19
I found recently something on Pinal Dev blog and some people were complaining about only views not scripted in right order.
whizzing_hornet
2010-01-12 18:56:02
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
2010-01-13 10:52:54
@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
2010-01-13 16:02:18