view is one type of database object which doesnt store any data but fetches its data from the tables on which the view is built.views can be of two types.one complex and other simple.depending on type of te view different perations are allowed on the views. advatages: 1.views are secure because we can fetch the data from different tables and present it to the user with cloumn alias's so tha user wont know the actual column names or table names. 2.instead of writing a huge join query which u most frequently use everytime and executing it, we can create a view using that query and just say for example "select * from view".this inturn fetches the data u want from the tables meeting ur requirements. 3.u can grant privilages to the user on the views instead of giving privilages on the actual tables.this sometimes help in security. these are just few advantages to bgin with.still more exist.Views also reduce the effort that is required for writing queries to access specific columns every time Advantages of Views 1) Restriction on data Access 2) Simplify to Data Manipulation 3) Import and Export to Data 4) Mergae Data How Can Create a View in Query Editor Window Or In sqlservermanagementstudio2005 Step 1) start your SQLSERVER MANAGEMENT STUDIO AND MAKE CONNECTION WITH DATABASE ENGINE AS GIVEN BELOW IN PICTURE.
IF YOU HAVE ALREADY ANY DATABASE U CAN USE TO HIM OR CAN MAKE NEW AS I TELLING U. CLICK ON NEW QUERY OPTION AND IT WILL OPEN NEW SQL OR QUEERY EDITOR WINDOW FOR YOU. CREATE NEW DATABASE WITH GIVEN COMMAND(QUEERY FOR DATABASE CREATING)Create Database dbempUse dbemp--first tableCREATE TABLE TBEMP VALUES(empno int identity PRIMARY KEY,ename varchar(50),empaddress varchar(50),empexperience varchar(50))--second tableCREATE TABLE TBEMPINFO VALUES(INTID INT IDENTITY PRIMARY KEY ,empcompany varchar(50),empdesignation varchar(50) null,emptime varchar(50) null,empno int)
Create Database dbempUse dbemp
--first tableCREATE TABLE TBEMP VALUES(empno int identity PRIMARY KEY,ename varchar(50),empaddress varchar(50),empexperience varchar(50))
--second tableCREATE TABLE TBEMPINFO VALUES(INTID INT IDENTITY PRIMARY KEY ,empcompany varchar(50),empdesignation varchar(50) null,emptime varchar(50) null,empno int) STEP 4: NOW RIGHT CLICK ON VIEW AND MAKE NEW VIEW WITH EASY WAY AS GIVEN IN PICTURE STEP 5: NOW YOU WILL SEE AS GIVEN BELOW WINDOW AND ALLOW TO ADD WHICH TABLE U WANT TO ADD IN A VIEW THEN OK OR CANCEL BEFORE ADD TO TABLES IN YOUR VIEW MAKE SURE THAT YOUR TABLES HAVE FOREIGN KEY AND NORMLIZE DATABASE TABLES. AFTER ADDING TABLE IN YOUR VIEW YOU WILL GET LIKE THIS VIEW AND QUERY WILL BE AUTOMAICALLY CREATED FOR U YOU CAN MODIFY OR CUSTOMIZE YOUR QUEREY ALSO. STEP 6: NOW YOU SAVE YOUR VIEW AND CAN EXECUTE. AFTER EXECUTING YOU WILL GET UR DESIRE RESULT. above given steps can also do in visual studio and can make your views It's really easy for u if u have fed with joins But in required output u will have to cutomize your query. It means u will have to do little effort,with this help ur time will save and effort less ,security more and also you will learn query optimization. be Happy and enjoy in programming !!! Note:-Friends Later i will post for you how to use views with asp.net