Re: updating multiple columns with subselect
"Dan Guzman" <guzmanda@nospam-online.sbcglobal.net> skrev i en meddelelse
news:VyCUj.15179$V14.7043@nlpi070.nbdc.sbc.com...
> > This is not supported in MSsql.
> >
> > update T1 set (theUpdatedValue, theOtherValue) =
> > (select theTop, theValue from T2 where T2.theKey = T1.theID)
> >
> > Is there a workaround?
>
> You can use the proprietary UPDATE...FROM syntax:
>
> UPDATE T1
> SET
> theUpdatedValue = T2.theTop,
> theOtherValue = T2.theValue
> FROM T2
> WHERE
> T2.theKey = T1.theID
>
Thanks, worked perfectly.
Now I can update my system can be updated, so customers can order stuff for
both their loved ones, and their wives, without the ordrers getting mixed up
:-) (I had delivery adress in the customer table, not the order table)
Leif |