|
以下是我用来delete duplicated Key的query. 但是它delete的是original records.
1。要如何把original records 留着,只是把不要的删除?
2。可以把这个query run的更加快吗?
SET NOCOUNT ON
SET ROWCOUNT 1
WHILE 1 = 1
BEGIN
DELETE FROM trs_billdetails
WHERE trsno IN (
select trsno
from trs_billdetails
where trsno like ('V004%')
group by trsno, billid,itemcode,plucode,basedqty,unitqty,unitprice
having count(trsno) > 1)
IF @@Rowcount = 0
BREAK ;
END
SET ROWCOUNT 0
|
|