Sql Server 2008 (and possibly most of the other versions): Management Studio has the option to “generate scripts”, which theoretically can contain a script a whole database with all objects (right-click, tasks, script generation). It works fine for most things, but when you use it to script all views / stored procedures / functions in the database, it generates a script that does not take into account dependencies between objects.
eg. If View A refers to function B, it will not necessarily first place function B in the script.
It takes a long time to unravel a large long script that is created in such a way that it is in order, which will work without errors.
There must be a better way. What is the best way to get around this, preferably without spending money? *
* (red gate ftw)
source share