Friday, March 23, 2012

Querstion: update on joined field

Is it possible to update the filed used in the inner join
Update t1 set t1.name=t2.name2
From t1 inner join t2 on t1.name = t2.nameYes you can update the table. The inner join serves to limit the rows to be
updated. Much easier than writing a WHERE clause for the t1.name clause.
Nathan H. Omukwenyi
"JIM.H." <JIMH@.discussions.microsoft.com> wrote in message
news:17C998CC-B9C4-42D0-9650-C7331D3A7613@.microsoft.com...
> Is it possible to update the filed used in the inner join
> Update t1 set t1.name=t2.name2
> From t1 inner join t2 on t1.name = t2.name
>|||On Tue, 6 Jun 2006 19:23:01 -0700, JIM.H. wrote:
>Is it possible to update the filed used in the inner join
>Update t1 set t1.name=t2.name2
>From t1 inner join t2 on t1.name = t2.name
>
Hi Jim,
Yes, this is possible, BUT:
1. The UPDATE ... FROM syntax is not standard and therefor not portable.
The syntax can allso become quite confusing.
2. If a row in the table to be updated is matched by more than one row
in the source table(s), the row will actually be updated several times
and only the "last" result sticks. Since the order of evaluation is
never guaranteed, the result will be undefined. Running such a query
won't cause an error or even a warning message!
--
Hugo Kornelis, SQL Server MVP

No comments:

Post a Comment