sql server - multiple Insert query for existing row in sql -


i have table have 10 columns. have insert data table. have insert statements. first insert statement insert data first 3 rows 1 source. want insert data next columns in same row using insert statements different source. these insert queries runs daily table order_warehouse_status, have 1 row daily transaction.

ex. table order_warehouse_status have 10 columns

printed_pps_shipment, printed_shipment_lines, printed_unit,  picking_scheduled_orders,  picking_scheduled_lines,  picking_scheduled_units,  pick_complete_orders,  pick_complete_lines,  pick_complete_units 

below 1st query insert data in first 3 columns. 2nd query should insert data next column in same row. how achieve this?

--1st query

insert order_warehouse_status (date , printed_pps_shipment,  printed_shipment_lines,  printed_unit)  select getdate(), count(v_c_ship_ship_id) printed_pps_shipment,         count(ship_l_id) printed_shipment_lines,         count(allocated_qty) printed_unit \ [stg_wms_status_pps_line_qty]  convert(date,inserted_date )=convert(date,getdate())        , shipment_status=2 

--2nd query

insert order_warehouse_status  (date, picking_scheduled_orders,   picking_scheduled_lines,   picking_scheduled_units)  select getdate(), count(v_c_ship_ship_id) picking_scheduled_orders,         count(ship_l_id) picking_scheduled_lines,         count(allocated_qty) picking_scheduled_units  stg_closed_received  convert(date,inserted_date )=convert(date,getdate())        , shipment_status=7 

thanks in advance

hi first query same insert , second query can update statement condition checking whether date today's date...

  update order_warehouse_status    set picking_scheduled_orders = i.picking_scheduled_orders,       picking_scheduled_lines =  i.picking_scheduled_lines,        picking_scheduled_units = i.picking_scheduled_units         from(select  count(v_c_ship_ship_id) picking_scheduled_orders,         count(ship_l_id) picking_scheduled_lines,         count(allocated_qty) picking_scheduled_units  stg_closed_received  convert(date,inserted_date )=convert(date,getdate())        , shipment_status=7)i convert (date,'date column of order_warehouse_status)           = convert(date,getdate()) 

no need update 'date' column because inserted in first query.hope work if inner select statement return 1 row..just check


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -