Updating views sql server

Views don’t necessarily exhibit the same capability.If you update a view, you’re actually updating its underlying table.IF ( OBJECT_ID('dbo.vw_students1') IS NOT NULL ) DROP VIEW dbo.vw_students1 GO CREATE VIEW dbo.vw_students1 AS SELECT lastname , firstname , (firstname ' ' lastname) as "Fullname_fl", (lastname ', ' firstname) as "Fullname_lf", birth_dttm, DATEDIFF(yy, birth_dttm, GETDATE()) - CASE WHEN MONTH(birth_dttm) .The name should be somewhat reflective of the purpose of the view. As you can see in our view we are formatting the first and last name.Just as rows in a base table lack any defined ordering, rows available through a view do not appear with any default sorting.

However, there’re so many restriction on view in order to make it updatable ( Even if we created the view strictly follow the rule, it might still give us hassle if we trying to update the view through programing language like c#.

After I add the error check, the auto-generated COMMIT line magically disappeared and it works perfect ever since.

I didn’t find out the reasoning behind of this and guess it might relate to that the delete is no more the last statement.

This pre-established query command is kept in the database dictionary.

Unlike ordinary base tables in a relational database, a view does not form part of the physical schema: as a result set, it is a virtual table computed or collated dynamically from data in the database when access to that view is requested.

696

Leave a Reply