• anupam.jha (8/26/2013)


    Sean Lange (8/26/2013)


    anupam.jha (8/26/2013)


    I need to create around 26000 Views whose scripts are ready.

    But, some of the views are dependent on other views. Thus, I am not able to create the Views all at once.

    How should i automate the view creation process and avoid any errors that may come due to non existence of the dependencies.

    Please Help.

    Thanks,

    AJ

    How many levels are they nested? What you are running into is why so many people can't stand nested views. It is a maintenance nightmare.

    Right! This is a nightmare situation.

    Perhaps the project which I am working on is a legacy system and it seems that the entire development is done in bits and pieces without considering such maintenance issues.

    Anyways, most of the views have 1 level of dependency but there are views which have multiple level of dependencies.

    Regards,

    AJ

    I assumed that with 26,000 views it wasn't a brand new system. 😛

    Is this a one time thing or something you need to do repeatedly? If it is a one time thing you can use the catalog views to determine which of your views have dependencies to objects that are views. Then rearrange your script so that you create all the "base level" views first, followed by the next level. Rinse and repeat if you have multiple nested levels.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/