Categories

.NET (1) CSS (5) OOP (1) PHP (2) SQL (5) SQL Server (8) TSQL (1)

Thursday, March 24, 2011

INSERT, DELETE, UPDATE in VIEW

A view can be Updated, deleted and inserted only if it has only one base table.
For example consider there is a table called book and it has view called Book_View. So we can update, delete and insert in that view and this view will insert the data in actual table “Book”. So if we have a view which contains more than one table then we can't perform these operations on that view.
Consider the view that list the books on the basis of category. So there would be join on book table and category table on categoryID column in this view. So we can’t perform updating,inserting and deleting operations on this view because SQL server will get confuse and will give error.

Using SQL SERVER Templates

SQL SERVER management studio has very handy feature using and creating Template Scripts. It has many built in template script which we can use e.g. creating Tables, Stored Procedures Functions etc. You can see the SQL SERVER built in template list by going to View à Template Explorer or using the short key Ctrl+Alt+T