SQL how to avoid duplicate insert in a table
- by user1624531
how to avoid duplicate insert in a table? I use below query to insert in to table:
insert into RefundDetails(ID,StatusModified,RefundAmount,OrderNumber)
select O.id,O.StatusModified,OI.RefundAmount,O.OrderNumber
from Monsoon.dbo.[Order] as O
WITH (NOLOCK) JOIN Monsoon.dbo.OrderItem as OI
WITH (NOLOCK)on O.Id = OI.OrderId
WHERE o.ID in (SELECT OrderID
FROM Mon2QB.dbo.monQB_OrderActivityView
WHERE ACTIVITYTYPE = 4 AND at BETWEEN '10/30/2012' AND '11/3/2012') AND (O.StatusModified < '11/3/2012')