How the SQL Server deals/handles the views? | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

How the SQL Server deals/handles the views?

Is it creating the view whenever a script is referring to it? Or it maintain the view after first built up and then keeps it refresh? Env.: SQL2000 Enterprise & Windows 2003 CanadaDBA
SQL Server Views are nothing but parsed SQL Statements stored in database. Whenever a query refers to the view, the view name is replaced by the definition of the view (query used in the view). Compilation, Optimization use this new query. Gaurav
Moderator
Man thrives, oddly enough, only in the presence of a challenging environment- L. Ron Hubbard

The views expressed here are those of the author and no one else. There are no warranties as to the reliability or accuracy of anything presented here.
Therefore, everytime I refer to a view, SQL server recreats it, right? My imagination was opposite and I thought once a view is created and referred, it would be kept updated.
How about the indexed views?
quote:Originally posted by gaurav_bindlish SQL Server Views are nothing but parsed SQL Statements stored in database. Whenever a query refers to the view, the view name is replaced by the definition of the view (query used in the view). Compilation, Optimization use this new query. Gaurav

CanadaDBA
Recreated? View does not have any identity in database just like stored procedure does not have any identity except that SP’s plan is cached once it has been used. So the data from the view is never stored anywhere except base tables. Materialized view however has different sceanario. Here the data is actually stored in database. Gaurav
Moderator
Man thrives, oddly enough, only in the presence of a challenging environment- L. Ron Hubbard

The views expressed here are those of the author and no one else. There are no warranties as to the reliability or accuracy of anything presented here.
]]>