Views in SQL Server
A view is a subset of a table and is very much equal to a table and does not contain any memory that's why it is called "Virtual Table".
The main difference between a Table and Views are-
A view is a subset of a table and is very much equal to a table and does not contain any memory that's why it is called "Virtual Table".
The main difference between a Table and Views are-

There are mainly 2 types of view -
- Simple view
- Complex View
Simple View - A view that is created using simple select statement is called a simple view.
Complex View - It is created by using select statement containing orderby, group by and joins.
As we have mentioned a view is an interface between end-user and the original table.
Simple View Example:
As we have mentioned a view is an interface between end-user and the original table.

Simple View Example:
- create view myview
- as
- select EmpId,Name,ContactNo from tbl_empdetails
- select * from myview

Complex View
Example:
Example:
- create view mycomplexview
- as
- select e.EmpId,e.Name,e.ContactNo,l.Location from tbl_empdetails e inner join tbl_Location l on e.EmpId=l.EmpId
- select * from mycomplexview
So here, I have created a complex view by joining 2 tables that are the following:
tbl_empdetails and tbl_Location.
Here are the two tables,
This is tbl_empdetails.
This is tbl_Location and here is my view.
tbl_empdetails and tbl_Location.
Here are the two tables,
This is tbl_empdetails.
This is tbl_Location and here is my view.
- select * from mycomplexview
So in this way we can create complex view as well as simple view on any table.
Now the main question that is raised in an interview is that can a view affect a table?
Means when we insert and update a view can it have any direct effect on the table.
The answer is yes.
Here I have explained how it actually affect the table.
Now this will affect its table as follows.
Thus this clearly indicate that updating the simple view has direct effect on the table.
Now, a complex view is the collection of columns from 2 or more table. In this case is it possible to update the complex view?
Answer- Yes we can update the complex view using number of ways. Here I am explaining one by one.
Now updating my complex view as follows.
Thus it clearly shows that the main table is updated also.

Santhakumar MunuswamyPosted Oct 18, 2015, 3:56 AM
Good one
Debendra DashPosted Oct 12, 2015, 2:33 PM
Thanks Pankaj for pointing me a good and important point...At a particular point of time we cannot update a complex view colums that is being the part of 2 or more table,but we can update one table column in a specific time...I will update this complete info...Thanks again....
Pankaj Kumar ChoudharyPosted Oct 12, 2015, 12:25 PM
Nice Article Sir.... At the end of article you describe that we can update a complex View.I think it is not a complete information about the update operation for a Complex view . Because if we use a update operation for a complex view that update the column of multiple table then error will occur that is " update is not possible for multiple table". which show that we can not update a complex view if update operation effect the column of multiple tables. So please also consider this point in your article because this incomplete information may be generate wrong concepts......
Muhammad Aqib ShehzadPosted Oct 12, 2015, 7:11 AM
good elaboration
Sibeesh VenuPosted Oct 12, 2015, 3:19 AM
Nice Share
Vinodh NarayananPosted Oct 12, 2015, 2:48 AM
thanks for sharing
Mukesh KumarPosted Oct 12, 2015, 2:29 AM
Nice one sir
Yashwant VishwakarmaPosted Oct 12, 2015, 12:50 AM
Thumbs Up Article :)
Nilesh JadavPosted Oct 12, 2015, 12:08 AM
Good one
Rajeesh MenothPosted Oct 11, 2015, 12:33 PM
Nice Share!
RakeshPosted Oct 11, 2015, 11:29 AM
Good share
Pawan ChandPosted Oct 11, 2015, 11:16 AM
tnk u
Ravi PatelPosted Oct 11, 2015, 11:10 AM
nice