I have 2 tables with values stored as below.
Table1
ReferranceID   StatusNumber   ServiceType            T2OpenDt          T1OpenDT
162987          399519        Orthopaedic Surgery       NULL           2011-08-19 
162987          399525        Acupuncture               NULL           2011-08-19 
162987          413405        Anesthesiology            NULL           2011-09-28 
162987          517174        Chiropractic              NULL           2012-04-26
Table2
ReferranceID StatusNumber   Status     T2OpenDate
162987       256033         Closed     2010-11-17 
162987       488518         ReOpen     2012-02-22 
The first table should be updated as below from the 2nd table. (i.e the Result values)
ReferranceID   StatusNumber   ServiceType               T2OpenDt          T1OpenDT
162987          399519        Orthopaedic Surgery       2010-11-17         2011-08-19 
162987          399525        Acupuncture               2010-11-17         2011-08-19 
162987          413405        Anesthesiology            2010-11-17         2011-09-28 
162987          517174        Chiropractic              2012-02-22         2012-04-26 
'2010-11-17' will be updated in 3 rows since the T2OpenDate is less than T1Opendate and there is only one occurance of 2012-02-22 since this date is slightly greater than other 3 top T1OpenDate and less than the 4th T1OpenDate.
Could anybody suggest me the UPDATE sqlquery for the above. Thank you so very much for helping me.
 
     
    