SP插入
INSERT CheckTemp (ChkCode,BarCode,ChkState, ChkTime,CounterID,ChkUserID,Sp_Id)
(SELECT @ChkCode,A.BarCode,0,getdate(),@Sc_Id,@ChkUserID,@Sp_Id
FROM ShopCounterStorage A
left join ProductModelInfo B on A.Pm_Id=B.Pm_Id
left join ExInStockInfo C on A.BarCode=C.BarCode
WHERE A.Sp_Id=@Sp_Id AND
(@Sc_Id=-1 OR Sc_Id=@Sc_Id) AND
(@Pq_Id=-1 OR A.Pq_Id=@Pq_Id) AND
(@Pc_Id=0 OR B.Pc_Id=@Pc_Id) AND
C.InStockType=1 AND ProdCterStor_State=5)
(SELECT @ChkCode,A.BarCode,0,getdate(),@Sc_Id,@ChkUserID,@Sp_Id
FROM ShopCounterStorage A
left join ProductModelInfo B on A.Pm_Id=B.Pm_Id
left join ExInStockInfo C on A.BarCode=C.BarCode
WHERE A.Sp_Id=@Sp_Id AND
(@Sc_Id=-1 OR Sc_Id=@Sc_Id) AND
(@Pq_Id=-1 OR A.Pq_Id=@Pq_Id) AND
(@Pc_Id=0 OR B.Pc_Id=@Pc_Id) AND
C.InStockType=1 AND ProdCterStor_State=5)