June 15, 2006 at 2:22 pm
Hi,
I want to merge two tables both has the same fields. For e.g. I have two tables Table A and Table B. Table A has two fields where as Table B has 18 fields. For both tables ID and atp_College fields are same. I have to update Table B with Table A where TableA.ID = TableB.ID.
Thanks in Advance,
Bhavna
June 15, 2006 at 2:49 pm
update b
set b.ColumnX = a.ColumnY
from tableB b
inner join tableA a
on b.ID = a.ID
June 16, 2006 at 7:19 am
Thanks Jeff, it worked.
June 16, 2006 at 7:42 am
I have another question, I also have to update another field called mem_type in the same update statement. That field is not coming from table A. For mem_type I have to check if mem_type is 'NULL' or mem_type is ' ' then mem_type = 'SEI'.
Thanks,
Bhavna
June 16, 2006 at 7:55 am
You could add a conditional update like this...
.... b.mem_type = case when (b.mem_type is null) or (b.mem_type = ' ') then 'SEI' else b.mem_type end ....
**ASCII stupid question, get a stupid ANSI !!!**
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply