Try,
update tableB
set
HasShipped = (select shipped from tableA as a where a.ordernum =
tableB.orderid),
ship_date = (select shipdate from tableA as a where a.ordernum =
tableB.orderid)
where
exists(select * from tableA as a where a.ordernum = tableB.orderid)
-- or
update b
set
b.HasShipped = a.shipped,
b.ship_date = a.shipdate
from
tableB as b
inner join
tableA as a
on b.orderid = a.ordernum
go
AMB
[quoted text, click to view] > TableA ---> TableB
> ---------- -----------
> ordernum = orderid
> shipped HasShipped
> shipdate ship_date
"stjulian" wrote:
> I have a need to update a table with data from another. They do not even
> share the same field names. although do share the same data types and
> meanings. I am just having a problem wrapping my head around this. I can't
> seem to shake the feeling that I am going to update the entire table by
> accident.
>
> The idea is to update an order table (B) with data from another type of
> order table (A). Sometimes TableA is blank, if that is important.
>
> The order ID's are the common links and are unique.
>
>
> for example:
>
> TableA ---> TableB
> ---------- -----------
> ordernum = orderid
> shipped HasShipped
> shipdate ship_date
>
>
>
>
> Thanks
> Julian
>
>
>
I have a need to update a table with data from another. They do not even
share the same field names. although do share the same data types and
meanings. I am just having a problem wrapping my head around this. I can't
seem to shake the feeling that I am going to update the entire table by
accident.
The idea is to update an order table (B) with data from another type of
order table (A). Sometimes TableA is blank, if that is important.
The order ID's are the common links and are unique.
for example:
TableA ---> TableB
---------- -----------
ordernum = orderid
shipped HasShipped
shipdate ship_date
Thanks
Julian