June 19, 2013 at 4:11 pm
Hi,
I'm confused how to solve this:
Using UPDATE, MERGE, table-valued UDF or what?:w00t:
I know using a cursor is possible but there are disadvantages...
tblA
colA1 colA2 colA3
=======================
C 15 NULL
D 17 NULL
G 18 NULL
L 19 NULL
R 20 NULL
tblB (the lookup table)
colB1 colB2 col3
=======================
28 15 1
34 17 1
35 18 1
36 18 0
37 18 0
42 19 1
43 20 0
44 20 1
To do:
Find in tblB the lines with col3 = 1 (exists only once for same colB2-value),
Then UPDATE tblA colA3 with value colB1. RI exists on colB2 = colA2
--
candide
________Panta rhei
June 19, 2013 at 4:44 pm
It is a simple UPDATE --
UPDATEtblA
SET colA3 = colB1
FROM tblB
WHERE colA2 = colB2
AND colB3 = 1
;
June 20, 2013 at 6:49 am
thx,
you saved my day
--
candide
________Panta rhei
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy