in my db structure there are tables in thousands and such tables are accessed by views (base views) and further different views are created on base views and so on.
I need a script that check base level views first then generate a script of views,
after that 2nd level views which are based on base views and generate a script and so on.
Right now, using sql management studio, when I click on Views on the left side, detail (view name) are shown at right using View > Object Explorer Details, by selecting all the views script file generates all views randomly which is creating problem, I want to get the sequence of scripts, (first come fist serve).
I just want to point out that this type of db structure may have serious performance impact. SQL Server's query optimizer is a "just good enough" query optimizer, meaning that SQL Server first estimates how efficiently it can perform a query, and whenever the optimized code is this efficient, no further optimization is being done. So, what does this mean in your case? Your innermost view may not be expanded, and any filtering from your outer views will not be done while reading the source tables, resulting in table scans of potentially large tables.