微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

插入偶尔丢失的行

如何解决插入偶尔丢失的行

我在查询下运行,有时这些查询会跳过几条记录插入到 newordersholdentry 中,但没有出现任何错误

但是如果在发现它丢失了一些订单记录后再次运行相同的查询,它将插入所有。

请告诉我可能是什么原因。

INSERT INTO newordersholdentry
(itemid,lookupcode,description,gamacode,ordered,IsForceItem,Scanned,Location,SortOrder
)
       SELECT ID,ItemLookupCode,Description,GamaCode,SUM(Qty) AS Qty,ForceItem,0 AS Scanned,SubDescription1,Sortorder
       FROM
       (
           SELECT Item.ID,Item.ItemLookupCode,Item.Description,NewOrderItems.GamaCode,NewOrderItems.Qty,Item.SubDescription1,Item.Binlocation,ISNULL(
           (
               SELECT TOP (1) SortSno
               FROM NewOrderPickPackSorting
               WHERE(Bin = LEFT(Item.SubDescription1,3))
           ),99999) AS Expr1,0 AS ForceItem,p.sortorder
           FROM NewOrderItems(NOLOCK)
                INNER JOIN Item(NOLOCK) ON NewOrderItems.GamaCode = Item.SubDescription2
                LEFT OUTER JOIN pickpath(NOLOCK) p ON concat(RTRIM(p.aisle),'-',p.section) = UPPER(LEFT(item.subdescription1,6))
           WHERE(NewOrderItems.discontinue = 0)
                AND (NewOrderItems.OrderID = 123456)
       ) AS t
        Group by ID,ItemLookupcode,GAMACODE,Expr1,BinLocation,sortorder

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。