I don’t know why every interviewer’s favorite question “Can we insert record using View ?” If you say Yes/No the interviewer will roaming around like so Can you update record using View? or Can you delete record using view ?
I hope everyone who is reading this article will be aware of what is view and how to create it ?
If not then need not to worry
“View can be see as a virtual table based on SQL SERVER result or in other world it is a layer above actual data tables” Or we can say when you want to hide actual table then you create a view wrapper”
You can easily create a View with following syntax
Let’s understand this by an example.
Suppose in I have a database with name “IndiandotnetDB” which has a table “tblStudentSource”
Now I created a view just for fetching records from tblStudentSource
CREATE VIEW StudentSourceView
Now you can fetch records directly from View as shown in below
SELECT * FROM StudentSourceView
You will get all the records from tblStudentSourceView
Now the Question “ Can you Insert record from View ?“
So the answer is specific condition you can.
In our scenario we will write following command and execute so the record will be added
So you are clear that we can Insert records from View.
In similar fashion we can update the records as shown below figure
We will following SQL statement as showing in figure in which we are going to update record no 2004 as shown in above figure
As shown record 2004’s FirstValue is updated to value “Updated”
Now in similar way we can delete the record using View.
Although there are certain other factor due to which “Insert/update/delete” is possible.
like we have only simple schema.
I will describe this later with more detail like scenario where we can not Insert/Uppdate/delete using view.
Till than Enjoy !!!