---
title: "SQL View"  
description: "In this blog describe the concept of sql view in sql server. SQL view is a virtual table. Here we give simple example of view.  A View is a Virtual Ta"  
author: "Anchal Kesharwani"  
published: 2014-08-12  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/672/sql-view  
category: "database"  
tags: ["database"]  
reading_time: 2 minutes  

---

# SQL View

In this blog [describe the concept](https://www.mindstick.com/forum/158622/describe-the-concept-of-a-divide-by-zero-exception-and-how-to-handle-it) of sql [view in sql](https://www.mindstick.com/blog/11175/view-in-sql) server. SQL view is a [virtual table](https://www.mindstick.com/interview/876/which-virtual-table-does-a-trigger-use). Here we give simple example of view.\

A View is a Virtual Table. It is not like a simple table, but is a virtual table which contains columns and data from different tables (may be one or more tables). A View does not contain any data, it is a set of queries that are applied to one or more tables that is stored within the [database](https://www.mindstick.com/articles/12226/use-of-database-in-sencha-extjs-and-insert-record-from-user-form-using-ajax) as an object. Once you have defined a view, you can [reference](https://www.mindstick.com/forum/774/reference-what-does-this-error-mean-in-php) it like any other table in a database.

Views are used for [security purposes](https://answers.mindstick.com/qa/39717/what-is-the-latest-technology-that-has-been-invented-or-is-going-to-be-invented-for-security-purposes) because they provide [encapsulation](https://www.mindstick.com/articles/12229/encapsulation-and-access-specifier) of the name of the table. Data is in the virtual table, not stored permanently. Views display only selected data.

##### Syntax

```
CREATE VIEW <view name> ASSELECT statementHere we create the table of department and employee.create table Departments( DepartID int identity(1,1) primary key,DepartmentName varchar(50))create table Employee( EmpID int identity(1,1) primary key,FirstName varchar(50),LastName varchar(50),DepartID int references Departments(DepartID))
```

##### Example 1

This is an example is a example of simple view which contain only [one table](https://www.mindstick.com/forum/538/copy-one-table-to-another-in-sql-server-automatically).

```
CREATE VIEW ShowEmployeeData ASSELECT * FROM EmployeeSELECT * FROM ShowEmployeeData
```

##### Output

![SQL View](https://www.mindstick.com/blogs/0246934a-7bd9-467d-a933-351db856938c/images/df46ed87-2bc3-49bc-871f-d32f76bd5e1e.png)

##### Example 2

This is an example for multiple table using join. It is also known as complex view.

```
CREATE VIEW ShowEmployee ASSELECT e1.FirstName,e1.LastName,e2.DepartmentName FROM Employee e1 INNER JOIN Departments e2ON e1.DepartID = e2.DepartID
```

##### Output

\

![SQL View](https://www.mindstick.com/blogs/0246934a-7bd9-467d-a933-351db856938c/images/aafc6a28-840d-421b-ac8a-5bc76eb0b542.png)

---

Original Source: https://www.mindstick.com/blog/672/sql-view

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
