Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Applies to:
SQL Server
Azure SQL Database
Azure SQL Managed Instance
Azure Synapse Analytics
Analytics Platform System (PDW)
You can create views in the SQL Server Database Engine by using SQL Server Management Studio or Transact-SQL. A view can be used for the following purposes:
To focus, simplify, and customize the perception each user has of the database.
As a security mechanism by allowing users to access data through the view, without granting the users permissions to directly access the underlying base tables.
To provide a backward compatible interface to emulate a table whose schema has changed.
A view can be created only in the current database.
A view can have a maximum of 1,024 columns.
Requires CREATE VIEW permission in the database and ALTER permission on the schema in which the view is being created.
In Object Explorer, expand the database where you want to create your new view.
Right-click the Views folder, then select New View....
In the Add Table dialog box, select the element or elements that you want to include in your new view from one of the following tabs: Tables, Views, Functions, and Synonyms.
Select Add, then select Close.
In the Diagram Pane, select the columns or other elements to include in the new view.
In the Criteria Pane, select additional sort or filter criteria for the columns.
On the File menu, select Save view name.
In the Choose Name dialog box, enter a name for the new view and select OK.
For more information about the query and view designer, see Query and View Designer Tools (Visual Database Tools).
In Object Explorer, connect to an instance of Database Engine.
On the Standard bar, select New Query.
Copy and paste the following example into the query window and select Execute.
USE AdventureWorks2022;
GO
CREATE VIEW HumanResources.EmployeeHireDate
AS
SELECT p.FirstName,
p.LastName,
e.HireDate
FROM HumanResources.Employee AS e
INNER JOIN Person.Person AS p
ON e.BusinessEntityID = p.BusinessEntityID;
GO
-- Query the view
SELECT FirstName,
LastName,
HireDate
FROM HumanResources.EmployeeHireDate
ORDER BY LastName;
GO
Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayTraining
Module
Create tables, views, and temporary objects - Training
This content is a part of Create tables, views, and temporary objects.
Certification
Microsoft Certified: Azure Database Administrator Associate - Certifications
Administer an SQL Server database infrastructure for cloud, on-premises and hybrid relational databases using the Microsoft PaaS relational database offerings.
Documentation
CREATE VIEW (Transact-SQL) - SQL Server
CREATE VIEW (Transact-SQL)
Learn about views, important database objects where the result set is defined by a query.
Modify Data Through a View - SQL Server
Modify Data Through a View