Create PROCEDURE [dbo].[LVS_Update_WaferInfo]
@LotIdvarchar(40),
@xmlData xml
as
BEGIN
delete W from LVS_WaferList W,
(
select distinct @LotId LotID,T.C.value ('CURRENTPASS[1]' , 'varchar(max)' ) as CurrentPass
from @xmlData.nodes ('//dt_result' ) as T(C)
) M
where M.LotID = W.LotID and M.CurrentPass = W.CurrentPass
insert into LVS_WaferList (LotID,CurrentPass,RingID,WaferFile,WaferLimit,ActionDate)
select distinct @LotId LotID,T.C.value ('CURRENTPASS[1]' , 'varchar(max)' ) as CurrentPass,
T.C.value ('RINGID[1]' , 'varchar(max)' ) as RingID,
T.C.value ('INVENTORISEDWAFERID[1]' , 'varchar(max)' ) as WaferFile,
T.C.value ('QUANTITY[1]' , 'int' ) as Qty,GETDATE()
from @xmlData.nodes ('//dt_result' ) as T(C)
END