update table1 set field1=table2.field1,field2=table2.field2 from table2 where table1.id=table2.id
update d set d.iprice=b.iprice,d.iunitcost=d.iprice/d.iquantity from rdrecord a,rdrecords b,rdrecord c,rdrecords d
where a.cdefine1=c.cdefine1 and a.id=b.id and c.id=d.id and a.crdcode='25' and a.cvouchtype='08' and c.crdcode='15' and c.cvouchtype='09' and a.ddate>=@datestart and a.ddate<=@dateend
select djid from (select DISTINCT djid,cwhcode,CONVERT(varchar(100), ddate, 23)ddate,cCuscode,cmaker,cmemo,cdepcode,cVenCode from dev_gb_rdrecord)a group by djid having count(*)>1