CREATE VIEW

CREATE VIEW#

Creates a view — a virtual table whose contents are defined by a query.

Syntax#

CREATE VIEW view name AS selectselect

Arguments#

view name

The name by which the view is identified within the virtual database.

select

A SELECT query that defines the rows and columns the view exposes.

Examples#

Create a view that exposes only the active products:

CREATE VIEW dbo.ActiveProduct AS
SELECT Id, Name, Price
FROM   dbo.Product
WHERE  Discontinued = 0;