Views can be used for data modification:
INSERT INTO vwStudentDetails1(Id, Name, Std_Course, Phone, Std_Grade)
VALUES (20, 'Sam Simon', 4, 98758, 2);
(1 row(s) affected)
Here a new row with Id=20 is inserted into the 'Students' table. A SELECT query can verify that the new row was added.
UPDATE vwStudentDetails1
SET Name='Billy James', Phone=27751
WHERE Id=20;
SELECT * FROM Students WHERE Id=20;
(1 row(s) affected)
Id Name Std_Course Phone Std_Grade
20 Billy James 4 27751 2
(1 row(s) affected)
In this example, the first statement updates the data, while the second statement is used to verify the results.
DELETE FROM vwStudentDetails WHERE Id=20;
(1 row(s) affected)
Here the row with Id=20 gets deleted from the 'Students' table. It can be verified by querying the table.
sp_helptext vwStudentDetails;
CREATE VIEW vwStudentDetails
AS
SELECT * FROM Students;
The above is the definition of the view, vwStudentDetails.
sp_depends vwStudentDetails;
In the current database, the specified object references the following:
name type updated selected column
dbo.Students user table no yes Id
dbo.Students user table no yes Name
dbo.Students user table no yes Std_Course
dbo.Students user table no yes Phone
dbo.Students user table no yes Std_Grade
The above example displays the dependencies of the view, vwStudentDetails.