Reputation: 1229
What is the right order in which we should create SQL Server objects? (This is for the installer order)?
I assume that the right order is
But however, I am confused, what if a View references a function? And, what if a function references a View?
Upvotes: 0
Views: 56
Reputation: 239636
There's no "generic" order in which you can create objects (you missed e.g. a CHECK constraint on a table that may use a function). If you want it 100% right, you need to analyse your specific set of database objects and ensure that they're created in an appropriate order, by analysing the individual dependencies.
As a more straightforward example, views can access table-valued functions. But table-valued functions may be based on views. So doing all of either first wouldn't always work.
Stored procedures can be created quite early in the process, thanks to Deferred Name Resolution. This is the only positive thing to be said for it.
Upvotes: 1