Since i am new with sql server, my question is
Can we update views?
Can we update real table data in views?
Since i am new with sql server, my question is
Can we update views?
Can we update real table data in views?
If you update a view you will actually be updating the underlying table. A view is nothing physical, just a representation of the data underneath it.
In most circumstances you can perform UPDATE statements via VIEWS as long as they're setup to cater for UPDATEs (you can read more about enabling views for UPDATES here: http://msdn.microsoft.com/en-us/library/25614805(v=vs.80).aspx ) but it's generally considered less-than-great practise to do so. It makes things become very convoluted so you'd have to have a good reason to be doing it that way.
Yes underlying table data can be updated by Updating a view.
The point to note here is, as long as the View is created based on one single table then direct "Update View" statement would work.
But if the view is created based on multiple tables then a direct Update statement won't work. We need to make use of "Instead of Triggers" in those scenarios.
GROUP BY
)
Commented
Aug 31, 2011 at 13:12