select i.* from tbl_POS_orderLineItems i with(nolock) where i.orderid = and i.itemIdentifier = and i.itemDesc = select s.skuId, s.maxorderqty from tbl_prd_skus s with(nolock) where s.sku = and s.ownerid = and s.fsl_tablecode = insert into tbl_POS_OrderLineItems ([orderid] ,[qty] ,[qty_unitMsr] ,[intIdentifier] ,[lineItem_Table] ,[lineItem_ID] ,[title] ,[itemDesc] ,[itemIdentifier] ,[maxOrderQty] ,[datestamp] ,[shp_qty] ,[shp_qty_unitMsr] ,[notShipped] ,[fseOpportunityStatus] ,[lineItemComment] ,[restoreDate]) VALUES (#_addLinesBack.orderId# ,#val(_qty)# ,'#_uom#' ,'#_lineToAdd.item#' ,'PSKU' ,#_skuId# ,'#_lineToAdd.item# - #_lineToAdd.item_description#' ,'#_lineToAdd.item_description#' ,'#_lineToAdd.item#' ,#_maxorderqty# ,'#_lineToAdd.datestamp#' ,#val(_qty)# ,'#_uom#' ,0 ,'?' ,'' ,getDate()) select o.orderId, o.status from tbl_POS_orders o with(nolock) where o.ownerId = and o.fsl_tablecode = and o.orderid = and o.status = 'CAN' update tbl_POS_OrderLineItems set shp_qty = null, shp_qty_unitMsr = null where orderid =