If I have two tables
Table A:
ID IOL Voced
1234 NULL NULL
Table B:
ID IOL Voced AdmitDate
1234 1 Null 7/1/2005
1234 2 3 7/3/2005
1234 Null NUll 7/5/2005
I would like to update Table A with the most current information from Table B. Here it would be the record from 7/5/2005 but if the values are null then I need to go back and get the last record where they are not null. So in Table A my record should read:
ID IOL Voced Admit Date
1234 2 3 7/5/2005
I can easily do this with another program but how would I accomplish this with T-sql?
I'm guessing some sort of loop. I don't see how a join would work here.
Table A:
ID IOL Voced
1234 NULL NULL
Table B:
ID IOL Voced AdmitDate
1234 1 Null 7/1/2005
1234 2 3 7/3/2005
1234 Null NUll 7/5/2005
I would like to update Table A with the most current information from Table B. Here it would be the record from 7/5/2005 but if the values are null then I need to go back and get the last record where they are not null. So in Table A my record should read:
ID IOL Voced Admit Date
1234 2 3 7/5/2005
I can easily do this with another program but how would I accomplish this with T-sql?
I'm guessing some sort of loop. I don't see how a join would work here.