8
Reply

How to create view in sql server

Pawan Shukla

Pawan Shukla

10y
1.7k
0
Reply

    create view myview as select * from mytable

    Create view AS --Write your Select Query here. --For naming convention use "vw_" before ViewName for User Defined ViewHope this'll help you.

    We have two types of Views in Sql Server. They are 1)Simple Views and 2) Complex Views Syntax for creating views CREATE VIEW vw_name AS SELECT column_names FROM table_nameSimple View: Simple Views are created on single table. In Simple Views, data can be Inserted, Updated and Deleted as shown in the below examples. Example on Simple View: --create view on single table create view vw_Employee as select empid,empname from [dbo].[employee]--select data from view select * from vw_Employee--insert data into simple view insert into [dbo].[vw_Employee] (empid,empname) values (101,'Roopa')--update data in simple view update vw_Employee set empname='Rani' where empid=1--delete data from simple view delete vw_Employee where empname='Rani'Complex View: If we are creating a view on more than one table it is know as Complex View. We can only update the Complex Views. Data cannot be inserted into or delete from Complex Views. Example on Complex View: --create view on multiple tables create view vw_Emp_Dept as select e.empid,e.empname,d.deptno,d.deptname from employee e inner join department d on e.empname= d.empname--select data from view select * from vw_Emp_Dept--update data in complex view update vw_Emp_Dept set deptno=20 where empname='Ravi'

    http://dotnet-munesh.blogspot.in/2013/12/view-state-in-dot-net.html

    http://www.aspdotnet-suresh.com/2012/11/viewstate-in-aspnet-with-example-in-c.html

    hey pawan for more information please read my artical http://www.c-sharpcorner.com/UploadFile/8af593/view-in-sql-server/hope it helps youthanks and regards Abhijit patil

    CREATE VIEW "viewname" AS --Select statement

    CREATE VIEW AS// SELECT QUERY HERE