The Gurus Guide to SQL Server Stored Procedures, XML, and HTML [Electronic resources]

Ken Henderson

نسخه متنی -صفحه : 223/ 74
نمايش فراداده

Chapter 9. Views

I want to personally thank all those who have doubted me in the past. All those who gave up on me, who thought little of me, who underestimated meyou have been a source of inspiration. You have caused me to work faster and try harder than I otherwise would have, an d, for that, I owe you a debt of gratitude.

H. W. Kenton

An SQL Server view object is a static query that you can use as a kind of virtual table in a SELECT, INSERT, UPDATE, or DELETE. A view consists of a SELECT statement stored permanently as a separate object using SQL's CREATE VIEW command. A view is typically used to encapsulate a complicated join or query so that it can be accessed like a table.

View columns can consist of columns from tables or other views, aggregates, constants, and expressions (computed columns). Some views can be updated; some can't. Whether a view can be updated depends largely on whether SQL Server can resolve an update to one of its rows to a single row in an underlying base table. All views must eventually reference a base table or nontabular expression (an expression that doesn't require a tableGETDATE(), for example), although views can be "nested," meaning that a view can reference other views as long as the dependence tree eventually resolves to base tables or nontabular expressions.