Visual Database Tools

Comparison of Queries and Views

Because queries and views have so many similarities, it is easy to overlook their differences.  This section briefly compares queries and views.

Storage Views are stored as part of a database design, but queries are not.  As you design a database, you can include views in the design for the following reasons:

Updating results The restrictions on updating result sets are different for views and queries.  For more information, see Rules for Updating Results.

Sorting results You can sort any query result, but you can sort a view only if the view includes the TOP clause.  For more information about the TOP clause, see Limiting Result Sets Using TOP and PERCENT.

Query plan generation A query plan is an internal strategy by which a database server tries to create result sets quickly.  A database server can establish a query plan for a view as soon as the view is saved.  For a query, however, a database server cannot establish a query plan until the query is actually run — that is, until the user explicitly demands the result set.

Parameterization You can create parameters for a query, but not for a view.  For more information about parameterized queries, see Creating General Purpose Queries.

Encryption A view can be encrypted, but a query cannot.  For more information see Encrypting Views.

See Also

Queries and Views