Why cannot update this simple view?

Why cannot update this simple view?

Post by JESS » Fri, 24 Jan 2003 06:54:20



I have a view (VIEW1) based on two tables: 'Customers'
and 'Orders'

One of them, called Customers, has a primary key called
IDCustomer

The other one, called Orders, has a foreign key called
IDCustomer and a field called Notes

This is the view (it works ok save for updating for the
Notes field)

SELECT dbo.Customers.IDCustomer, dbo.Orders.Notes FROM
dbo.Orders INNER JOIN dbo.Customers ON
dbo.Customers.IDCustomer = dbo.Orders.IDCustomer

I cannot update the 'notes' field when it is displayed by
using the EM

("Insufficient key column information for updating or
refreshing") is triggered by SQL

So I have tried to implement the follow trigger which does
not seem to work -even though it generates no errors when
executed

CREATE   TRIGGER TR2 ON  VIEW1

INSTEAD OF UPDATE

AS

BEGIN

        IF (SELECT COUNT(*) FROM Inserted) > 0

        BEGIN

        UPDATE Orders

        SET Notes  = i.Notes

        FROM Orders AS OR

        JOIN Inserted AS i

        ON i.Notes = OR.Notes

END

 
 
 

Why cannot update this simple view?

Post by Joe Celk » Fri, 24 Jan 2003 07:07:35


The SQL-92 standard is actually very conservative about what VIEWs are
updatable.  They have to be based on:

  (1) a SELECT statement on one and only one table; this can go thru
several layers of VIEWs on top of VIEWs, however.

  (2) The VIEW must include all the columns of a key (i.e. a UNIQUE or
PRIMARY KEY constraint) in the base table

  (3) All columns not shown in the VIEW must have default values or be
NULL-able (if you think about it for a minute, this lets you construct
and insert a complete row into the base table).

The whole idea is that an updatable VIEW looks and behaves pretty much
like a base table, but slightly restricted as to what you can see.  One
row in the VIEW maps to exactly one row in the base table from which it
is drawn.  

However, other views are updatable and some vendors support more than
the basic version given in the SQL-92 Standard. The VIEW must have an
INSERT, UPDATE and DELETE rule under the covers which maps its rows back
to a single row in the base table(s).

for practical information with the fastest reading time is Nathan
Goodman in InfoDB.  He discusses:

    1)  Projection from a single table
    2)  Selection/Projection from a single table
    3)  UNION VIEWs
    4)  Set Difference VIEWs
    5)  One-to-one joins
    6)  One-to-one outer joins
    7)  One-to-many outer joins
    8)  One-to-one outer joins
    8)  Many-to-many joins
    9)  Translated and coded fields

Codd, E. F.; THE RELATIONAL MODEL FOR DATABASE MANAGEMENT: VERSION TWO;
"RV-6 VIEW Updating"; (ISBN 0-201-14192-2).

Date, C. J. & Hugh Darwen; RELATIONAL DATABASE WRITINGS -1989-1991;
"Role of Functional Dependencies in Query Decomposition"; (ISBN
0-201-54303-6).

Date, C. J.; RELATIONAL DATABASE: SELECTED WRITINGS; "Updating VIEWs";
(ISBN 0-201-14196-5).

Goodman, Nathan; INFODB Vol 5, No 2 (Summer 1990); "VIEW Update is
Practical".

Umeshar, Dayal & P. A. Bernstein; ACM TRANSACTIONS ON DATABASE SYSTEMS
Vol 7, No 3 (Dec 1982); "On the Correct Translation of Update Operations
on Relational VIEWs".

Another feature, which is not used enough, is the WITH CHECK OPTION
clause on a VIEW.  It is a bit tricky, but if you would like I can post
a section from SQL FOR SMARTIES on this feature.  

--CELKO--
 ===========================
 Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, datatypes, etc. in your
schema are.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

 
 
 

Why cannot update this simple view?

Post by BP Margoli » Fri, 24 Jan 2003 07:39:43


Jess,

If I'm understanding you correctly, you have a 1-to-many relationship
between the Customers and Orders tables (1 customer can place many orders).

In the view you posted, it appears that you are not including in the select
list the primary key from the Orders table, so SQL Server does not know
which row in the Orders table you want to update.

Try seeing if the following view allows you to update the Notes column in
the Orders table:

SELECT Customers.IDCustomer, Orders.PK, Orders.Notes
FROM  dbo.Orders
INNER JOIN dbo.Customers
  ON  (dbo.Customers.IDCustomer = dbo.Orders.IDCustomer)

where Orders.PK is the primary key of the Orders table.

-------------------------------------------
BP Margolin
Please reply only to the newsgroups.
When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc.) which
can be cut and pasted into Query Analyzer is appreciated.


Quote:> I have a view (VIEW1) based on two tables: 'Customers'
> and 'Orders'

> One of them, called Customers, has a primary key called
> IDCustomer

> The other one, called Orders, has a foreign key called
> IDCustomer and a field called Notes

> This is the view (it works ok save for updating for the
> Notes field)

> SELECT dbo.Customers.IDCustomer, dbo.Orders.Notes FROM
> dbo.Orders INNER JOIN dbo.Customers ON
> dbo.Customers.IDCustomer = dbo.Orders.IDCustomer

> I cannot update the 'notes' field when it is displayed by
> using the EM

> ("Insufficient key column information for updating or
> refreshing") is triggered by SQL

> So I have tried to implement the follow trigger which does
> not seem to work -even though it generates no errors when
> executed

> CREATE   TRIGGER TR2 ON  VIEW1

> INSTEAD OF UPDATE

> AS

> BEGIN

> IF (SELECT COUNT(*) FROM Inserted) > 0

> BEGIN

> UPDATE Orders

> SET Notes  = i.Notes

> FROM Orders AS OR

> JOIN Inserted AS i

> ON i.Notes = OR.Notes

> END

 
 
 

Why cannot update this simple view?

Post by JESS » Fri, 24 Jan 2003 07:49:29


Thanks for your answer. My question is that this view can
be updated with a stored procedure and not from EM. The
type of JOIN is an INNER one (INNER JOIN)

This message had an error. This is the message with no
errors:

There was a mistake in my other message. This is ok

I have a view (VIEW1) based on two tables: 'Customers'
and 'Orders'

One of them, called Customers, has a primary key called
IDCustomer

The other one, called Orders, has a foreign key called
IDCustomer and a field called Notes

This is the view (it works ok save for updating for the
Notes field)

SELECT dbo.Customers.IDCustomer, dbo.Orders.Notes FROM
dbo.Orders INNER JOIN dbo.Customers ON
dbo.Customers.IDCustomer = dbo.Orders.IDCustomer

I cannot update the 'notes' field when it is displayed by
using the EM

("Insufficient key column information for updating or
refreshing") is triggered by SQL

So I have tried to implement the follow trigger which does
not seem to work -even though it generates no errors when
executed

CREATE   TRIGGER TR2 ON  VIEW1

INSTEAD OF UPDATE

AS

BEGIN

        IF (SELECT COUNT(*) FROM Inserted) > 0

        BEGIN

        UPDATE Orders

        SET Notes  = i.Notes

        FROM Orders AS OR

        JOIN Inserted AS i

        ON i.IDCustomer = OR.IDCustomer

END

I can update this view by using the following fragment of
code implemented in a SP

UPDATE VIEW1

        SET VIEW1.Notes  = i.Notes

        FROM dbo.Orders AS OS

        JOIN Inserted

        ON Inserted.IDCustomer = OS.IDCustomer

Can anybody tell me what is going on?. Why can I update
this view with the above code and not from EM or a datagrid
 in VISUAL Basic?

*************************
END

Quote:>-----Original Message-----
>Jess,

>If I'm understanding you correctly, you have a 1-to-many
relationship
>between the Customers and Orders tables (1 customer can
place many orders).

>In the view you posted, it appears that you are not

including in the select
Quote:>list the primary key from the Orders table, so SQL Server
does not know
>which row in the Orders table you want to update.

>Try seeing if the following view allows you to update the
Notes column in
>the Orders table:

>SELECT Customers.IDCustomer, Orders.PK, Orders.Notes
>FROM  dbo.Orders
>INNER JOIN dbo.Customers
>  ON  (dbo.Customers.IDCustomer = dbo.Orders.IDCustomer)

>where Orders.PK is the primary key of the Orders table.

>-------------------------------------------
>BP Margolin
>Please reply only to the newsgroups.
>When posting, inclusion of SQL (CREATE TABLE ...,

INSERT ..., etc.) which

- Show quoted text -

>can be cut and pasted into Query Analyzer is appreciated.



>> I have a view (VIEW1) based on two tables: 'Customers'
>> and 'Orders'

>> One of them, called Customers, has a primary key called
>> IDCustomer

>> The other one, called Orders, has a foreign key called
>> IDCustomer and a field called Notes

>> This is the view (it works ok save for updating for the
>> Notes field)

>> SELECT dbo.Customers.IDCustomer, dbo.Orders.Notes FROM
>> dbo.Orders INNER JOIN dbo.Customers ON
>> dbo.Customers.IDCustomer = dbo.Orders.IDCustomer

>> I cannot update the 'notes' field when it is displayed
by
>> using the EM

>> ("Insufficient key column information for updating or
>> refreshing") is triggered by SQL

>> So I have tried to implement the follow trigger which
does
>> not seem to work -even though it generates no errors
when
>> executed

>> CREATE   TRIGGER TR2 ON  VIEW1

>> INSTEAD OF UPDATE

>> AS

>> BEGIN

>> IF (SELECT COUNT(*) FROM Inserted) > 0

>> BEGIN

>> UPDATE Orders

>> SET Notes  = i.Notes

>> FROM Orders AS OR

>> JOIN Inserted AS i

>> ON i.Notes = OR.Notes

>> END

>.

 
 
 

Why cannot update this simple view?

Post by BP Margoli » Fri, 24 Jan 2003 08:14:44


Jess,

EM uses ODBC to connect to and retrieve data from SQL Server. ODBC needs to
know the exact row that is being updated in the Orders table. Since the
output of the view, apparently, does not include the primary key of the
Orders table, EM cannot generate the appropriate T-SQL to update the Notes
column in the Orders table.

Unless you can change the definition of the view to include the primary key
of the Orders table, nothing is going to change the behavior of EM.

-------------------------------------------
BP Margolin
Please reply only to the newsgroups.
When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc.) which
can be cut and pasted into Query Analyzer is appreciated.


> Thanks for your answer. My question is that this view can
> be updated with a stored procedure and not from EM. The
> type of JOIN is an INNER one (INNER JOIN)

> This message had an error. This is the message with no
> errors:

> There was a mistake in my other message. This is ok

> I have a view (VIEW1) based on two tables: 'Customers'
> and 'Orders'

> One of them, called Customers, has a primary key called
> IDCustomer

> The other one, called Orders, has a foreign key called
> IDCustomer and a field called Notes

> This is the view (it works ok save for updating for the
> Notes field)

> SELECT dbo.Customers.IDCustomer, dbo.Orders.Notes FROM
> dbo.Orders INNER JOIN dbo.Customers ON
> dbo.Customers.IDCustomer = dbo.Orders.IDCustomer

> I cannot update the 'notes' field when it is displayed by
> using the EM

> ("Insufficient key column information for updating or
> refreshing") is triggered by SQL

> So I have tried to implement the follow trigger which does
> not seem to work -even though it generates no errors when
> executed

> CREATE   TRIGGER TR2 ON  VIEW1

> INSTEAD OF UPDATE

> AS

> BEGIN

> IF (SELECT COUNT(*) FROM Inserted) > 0

> BEGIN

> UPDATE Orders

> SET Notes  = i.Notes

> FROM Orders AS OR

> JOIN Inserted AS i

> ON i.IDCustomer = OR.IDCustomer

> END

> I can update this view by using the following fragment of
> code implemented in a SP

> UPDATE VIEW1

> SET VIEW1.Notes  = i.Notes

> FROM dbo.Orders AS OS

> JOIN Inserted

> ON Inserted.IDCustomer = OS.IDCustomer

> Can anybody tell me what is going on?. Why can I update
> this view with the above code and not from EM or a datagrid
>  in VISUAL Basic?

> *************************
> END

> >-----Original Message-----
> >Jess,

> >If I'm understanding you correctly, you have a 1-to-many
> relationship
> >between the Customers and Orders tables (1 customer can
> place many orders).

> >In the view you posted, it appears that you are not
> including in the select
> >list the primary key from the Orders table, so SQL Server
> does not know
> >which row in the Orders table you want to update.

> >Try seeing if the following view allows you to update the
> Notes column in
> >the Orders table:

> >SELECT Customers.IDCustomer, Orders.PK, Orders.Notes
> >FROM  dbo.Orders
> >INNER JOIN dbo.Customers
> >  ON  (dbo.Customers.IDCustomer = dbo.Orders.IDCustomer)

> >where Orders.PK is the primary key of the Orders table.

> >-------------------------------------------
> >BP Margolin
> >Please reply only to the newsgroups.
> >When posting, inclusion of SQL (CREATE TABLE ...,
> INSERT ..., etc.) which
> >can be cut and pasted into Query Analyzer is appreciated.



> >> I have a view (VIEW1) based on two tables: 'Customers'
> >> and 'Orders'

> >> One of them, called Customers, has a primary key called
> >> IDCustomer

> >> The other one, called Orders, has a foreign key called
> >> IDCustomer and a field called Notes

> >> This is the view (it works ok save for updating for the
> >> Notes field)

> >> SELECT dbo.Customers.IDCustomer, dbo.Orders.Notes FROM
> >> dbo.Orders INNER JOIN dbo.Customers ON
> >> dbo.Customers.IDCustomer = dbo.Orders.IDCustomer

> >> I cannot update the 'notes' field when it is displayed
> by
> >> using the EM

> >> ("Insufficient key column information for updating or
> >> refreshing") is triggered by SQL

> >> So I have tried to implement the follow trigger which
> does
> >> not seem to work -even though it generates no errors
> when
> >> executed

> >> CREATE   TRIGGER TR2 ON  VIEW1

> >> INSTEAD OF UPDATE

> >> AS

> >> BEGIN

> >> IF (SELECT COUNT(*) FROM Inserted) > 0

> >> BEGIN

> >> UPDATE Orders

> >> SET Notes  = i.Notes

> >> FROM Orders AS OR

> >> JOIN Inserted AS i

> >> ON i.Notes = OR.Notes

> >> END

> >.

 
 
 

Why cannot update this simple view?

Post by JESS » Fri, 24 Jan 2003 09:08:43


Thanks

I have include all of the records and it does not seem to
work. The problem is that this view is generated in a
datagrid in Visual Basic. Therefore it should be updateable

The trigger works perfectly ok with the UPDATE stored
procedure, but not with EM and a datagrid in VB.

Can you think of a way to make this view updatable in EM
and/or Visual Basic?

Quote:>-----Original Message-----
>Jess,

>EM uses ODBC to connect to and retrieve data from SQL

Server. ODBC needs to
Quote:>know the exact row that is being updated in the Orders
table. Since the
>output of the view, apparently, does not include the
primary key of the
>Orders table, EM cannot generate the appropriate T-SQL to
update the Notes
>column in the Orders table.

>Unless you can change the definition of the view to

include the primary key
Quote:>of the Orders table, nothing is going to change the
behavior of EM.

>-------------------------------------------
>BP Margolin
>Please reply only to the newsgroups.
>When posting, inclusion of SQL (CREATE TABLE ...,

INSERT ..., etc.) which
>can be cut and pasted into Query Analyzer is appreciated.



>> Thanks for your answer. My question is that this view
can
>> be updated with a stored procedure and not from EM. The
>> type of JOIN is an INNER one (INNER JOIN)

>> This message had an error. This is the message with no
>> errors:

>> There was a mistake in my other message. This is ok

>> I have a view (VIEW1) based on two tables: 'Customers'
>> and 'Orders'

>> One of them, called Customers, has a primary key called
>> IDCustomer

>> The other one, called Orders, has a foreign key called
>> IDCustomer and a field called Notes

>> This is the view (it works ok save for updating for the
>> Notes field)

>> SELECT dbo.Customers.IDCustomer, dbo.Orders.Notes FROM
>> dbo.Orders INNER JOIN dbo.Customers ON
>> dbo.Customers.IDCustomer = dbo.Orders.IDCustomer

>> I cannot update the 'notes' field when it is displayed
by
>> using the EM

>> ("Insufficient key column information for updating or
>> refreshing") is triggered by SQL

>> So I have tried to implement the follow trigger which
does
>> not seem to work -even though it generates no errors
when
>> executed

>> CREATE   TRIGGER TR2 ON  VIEW1

>> INSTEAD OF UPDATE

>> AS

>> BEGIN

>> IF (SELECT COUNT(*) FROM Inserted) > 0

>> BEGIN

>> UPDATE Orders

>> SET Notes  = i.Notes

>> FROM Orders AS OR

>> JOIN Inserted AS i

>> ON i.IDCustomer = OR.IDCustomer

>> END

>> I can update this view by using the following fragment
of
>> code implemented in a SP

>> UPDATE VIEW1

>> SET VIEW1.Notes  = i.Notes

>> FROM dbo.Orders AS OS

>> JOIN Inserted

>> ON Inserted.IDCustomer = OS.IDCustomer

>> Can anybody tell me what is going on?. Why can I update
>> this view with the above code and not from EM or a
datagrid
>>  in VISUAL Basic?

>> *************************
>> END

>> >-----Original Message-----
>> >Jess,

>> >If I'm understanding you correctly, you have a 1-to-
many
>> relationship
>> >between the Customers and Orders tables (1 customer can
>> place many orders).

>> >In the view you posted, it appears that you are not
>> including in the select
>> >list the primary key from the Orders table, so SQL
Server
>> does not know
>> >which row in the Orders table you want to update.

>> >Try seeing if the following view allows you to update
the
>> Notes column in
>> >the Orders table:

>> >SELECT Customers.IDCustomer, Orders.PK, Orders.Notes
>> >FROM  dbo.Orders
>> >INNER JOIN dbo.Customers
>> >  ON  (dbo.Customers.IDCustomer =

dbo.Orders.IDCustomer)

- Show quoted text -

>> >where Orders.PK is the primary key of the Orders table.

>> >-------------------------------------------
>> >BP Margolin
>> >Please reply only to the newsgroups.
>> >When posting, inclusion of SQL (CREATE TABLE ...,
>> INSERT ..., etc.) which
>> >can be cut and pasted into Query Analyzer is
appreciated.



>> >> I have a view (VIEW1) based on two
tables: 'Customers'
>> >> and 'Orders'

>> >> One of them, called Customers, has a primary key
called
>> >> IDCustomer

>> >> The other one, called Orders, has a foreign key
called
>> >> IDCustomer and a field called Notes

>> >> This is the view (it works ok save for updating for
the
>> >> Notes field)

>> >> SELECT dbo.Customers.IDCustomer, dbo.Orders.Notes
FROM
>> >> dbo.Orders INNER JOIN dbo.Customers ON
>> >> dbo.Customers.IDCustomer = dbo.Orders.IDCustomer

>> >> I cannot update the 'notes' field when it is
displayed
>> by
>> >> using the EM

>> >> ("Insufficient key column information for updating or
>> >> refreshing") is triggered by SQL

>> >> So I have tried to implement the follow trigger which
>> does
>> >> not seem to work -even though it generates no errors
>> when
>> >> executed

>> >> CREATE   TRIGGER TR2 ON  VIEW1

>> >> INSTEAD OF UPDATE

>> >> AS

>> >> BEGIN

>> >> IF (SELECT COUNT(*) FROM Inserted) > 0

>> >> BEGIN

>> >> UPDATE Orders

>> >> SET Notes  = i.Notes

>> >> FROM Orders AS OR

>> >> JOIN Inserted AS i

>> >> ON i.Notes = OR.Notes

>> >> END

>> >.

>.

 
 
 

Why cannot update this simple view?

Post by Steve Kas » Fri, 24 Jan 2003 09:29:01


Jess,

  To add to BPs remarks, what you are trying to do (and failing at) in
EM is not the same as what your sp does successfully.

  Your sp updates the Notes column for *every* row of Orders
containing a specific IDCustomer value.

  While it may not happen in your table, what if you have two rows
of Orders with IDCustomer = 101?  In the view, the only columns
visible are IDCustomer and Notes, but you see both of these rows
in the view and can try to update Notes in either one.  The sp upates Notes
for these two rows together, since it updates based on IDCustomer = 101.
But in EM, you are trying to update only one of these Notes columns.
What row of Orders needs to be updated?  There is no way for EM
to know.  You might say "this one", the one whose Notes column I'm
updating.  Well, the value of IDCustomer and the value of Notes are
not a key or unique column for the table, so EM won't try to use those
to identify the row.  The other IDCustomer =101 might even have the
same contents of Notes, and then no update is possible.  Since the
IDOrder column is not in the view, there is nothing in the view row
you are updating that can be used to determine what to update in the
Orders table.  This is not a problem in the sp, since you aren't trying
to update only one row.

Steve Kass
Drew University


>Thanks for your answer. My question is that this view can
>be updated with a stored procedure and not from EM. The
>type of JOIN is an INNER one (INNER JOIN)

>This message had an error. This is the message with no
>errors:

>There was a mistake in my other message. This is ok

>I have a view (VIEW1) based on two tables: 'Customers'
>and 'Orders'

>One of them, called Customers, has a primary key called
>IDCustomer

>The other one, called Orders, has a foreign key called
>IDCustomer and a field called Notes

>This is the view (it works ok save for updating for the
>Notes field)

>SELECT dbo.Customers.IDCustomer, dbo.Orders.Notes FROM
>dbo.Orders INNER JOIN dbo.Customers ON
>dbo.Customers.IDCustomer = dbo.Orders.IDCustomer

>I cannot update the 'notes' field when it is displayed by
>using the EM

>("Insufficient key column information for updating or
>refreshing") is triggered by SQL

>So I have tried to implement the follow trigger which does
>not seem to work -even though it generates no errors when
>executed

>CREATE   TRIGGER TR2 ON  VIEW1

>INSTEAD OF UPDATE

>AS

>BEGIN

>    IF (SELECT COUNT(*) FROM Inserted) > 0

>    BEGIN

>    UPDATE Orders

>    SET Notes  = i.Notes

>    FROM Orders AS OR

>    JOIN Inserted AS i

>    ON i.IDCustomer = OR.IDCustomer

>END

>I can update this view by using the following fragment of
>code implemented in a SP

>UPDATE VIEW1

>    SET VIEW1.Notes  = i.Notes

>    FROM dbo.Orders AS OS

>    JOIN Inserted

>    ON Inserted.IDCustomer = OS.IDCustomer

>Can anybody tell me what is going on?. Why can I update
>this view with the above code and not from EM or a datagrid
> in VISUAL Basic?

>*************************
>END

>>-----Original Message-----
>>Jess,

>>If I'm understanding you correctly, you have a 1-to-many

>relationship

>>between the Customers and Orders tables (1 customer can

>place many orders).

>>In the view you posted, it appears that you are not

>including in the select

>>list the primary key from the Orders table, so SQL Server

>does not know

>>which row in the Orders table you want to update.

>>Try seeing if the following view allows you to update the

>Notes column in

>>the Orders table:

>>SELECT Customers.IDCustomer, Orders.PK, Orders.Notes

>>FROM  dbo.Orders

>>INNER JOIN dbo.Customers
>> ON  (dbo.Customers.IDCustomer = dbo.Orders.IDCustomer)

>>where Orders.PK is the primary key of the Orders table.

>>-------------------------------------------
>>BP Margolin
>>Please reply only to the newsgroups.
>>When posting, inclusion of SQL (CREATE TABLE ...,

>INSERT ..., etc.) which

>>can be cut and pasted into Query Analyzer is appreciated.



>>>I have a view (VIEW1) based on two tables: 'Customers'
>>>and 'Orders'

>>>One of them, called Customers, has a primary key called
>>>IDCustomer

>>>The other one, called Orders, has a foreign key called
>>>IDCustomer and a field called Notes

>>>This is the view (it works ok save for updating for the
>>>Notes field)

>>>SELECT dbo.Customers.IDCustomer, dbo.Orders.Notes FROM
>>>dbo.Orders INNER JOIN dbo.Customers ON
>>>dbo.Customers.IDCustomer = dbo.Orders.IDCustomer

>>>I cannot update the 'notes' field when it is displayed

>by

>>>using the EM

>>>("Insufficient key column information for updating or
>>>refreshing") is triggered by SQL

>>>So I have tried to implement the follow trigger which

>does

>>>not seem to work -even though it generates no errors

>when

>>>executed

>>>CREATE   TRIGGER TR2 ON  VIEW1

>>>INSTEAD OF UPDATE

>>>AS

>>>BEGIN

>>>IF (SELECT COUNT(*) FROM Inserted) > 0

>>>BEGIN

>>>UPDATE Orders

>>>SET Notes  = i.Notes

>>>FROM Orders AS OR

>>>JOIN Inserted AS i

>>>ON i.Notes = OR.Notes

>>>END

>>.