Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- ITEM WAREHOUSE CLONE
- This script will copy the records for one warehouse into another warehouse,
- using the values from the original warehouse. Check the field listing to be sure
- it matches the itemwhse schema of you application database. Test against a pilot
- database before using in a production environment. Code provided with no guarantee
- or warranty.
- **/
- -- Set the application database to execute against:
- USE CSI_App;
- DECLARE @whse_A AS WhseType;
- DECLARE @whse_B AS WhseType;
- -- Set your old and new warehouses here:
- SET @whse_A ='MAIN';
- SET @whse_B = 'NEW';
- -- Insert the new records:
- BEGIN TRANSACTION @CloneItemWarehouse;
- INSERT INTO [dbo].[itemwhse] (
- [item]
- ,[whse]
- ,[qty_on_hand]
- ,[qty_alloc_co]
- ,[alloc_trn]
- ,[qty_trans]
- ,[qty_ordered]
- ,[qty_mrb]
- ,[qty_sold_ytd]
- ,[qty_pur_ytd]
- ,[trn_in_ytd]
- ,[trn_out_ytd]
- ,[qty_reorder]
- ,[sales_ytd]
- ,[sales_ptd]
- ,[cycle_freq]
- ,[last_cycle]
- ,[cnt_in_proc]
- ,[cycle_flag]
- ,[cycle_type]
- ,[phy_inv_qty]
- ,[phy_inv_dte]
- ,[qty_wip]
- ,[qty_rsvd_co]
- ,[replen_po_num]
- ,[replen_ps_num]
- ,[replen_trn_num]
- ,[NoteExistsFlag]
- ,[RecordDate]
- ,[RowPointer]
- ,[CreatedBy]
- ,[UpdatedBy]
- ,[CreateDate]
- ,[InWorkflow]
- ,[count_sequence]
- ,[last_count_qty_on_hand]
- ,[unit_cost]
- ,[lst_u_cost]
- ,[avg_u_cost]
- ,[asm_setup]
- ,[asm_run]
- ,[asm_matl]
- ,[asm_tool]
- ,[asm_fixture]
- ,[asm_other]
- ,[asm_fixed]
- ,[asm_var]
- ,[asm_outside]
- ,[comp_setup]
- ,[comp_run]
- ,[comp_matl]
- ,[comp_tool]
- ,[comp_fixture]
- ,[comp_other]
- ,[comp_fixed]
- ,[comp_var]
- ,[comp_outside]
- ,[sub_matl]
- ,[cur_u_cost]
- ,[unit_mat_cost]
- ,[unit_duty_cost]
- ,[unit_freight_cost]
- ,[unit_brokerage_cost]
- ,[unit_insurance_cost]
- ,[unit_loc_frt_cost]
- ,[cur_mat_cost]
- ,[cur_duty_cost]
- ,[cur_freight_cost]
- ,[cur_brokerage_cost]
- ,[cur_insurance_cost]
- ,[cur_loc_frt_cost]
- ,[matl_cost]
- ,[lbr_cost]
- ,[fovhd_cost]
- ,[vovhd_cost]
- ,[out_cost]
- ,[cur_matl_cost]
- ,[cur_lbr_cost]
- ,[cur_fovhd_cost]
- ,[cur_vovhd_cost]
- ,[cur_out_cost]
- ,[avg_matl_cost]
- ,[avg_lbr_cost]
- ,[avg_fovhd_cost]
- ,[avg_vovhd_cost]
- ,[avg_out_cost]
- ,[min_consignment_qty]
- ,[max_consignment_qty]
- ,[qty_contained]
- ,[fs_p_m_t_code]
- ,[fs_supply_whse]
- ,[fs_vend_num]
- ,[fs_order_min]
- ,[fs_order_max]
- ,[fs_order_mult]
- ,[fs_days_supply]
- ,[fs_consumable]
- ,[fs_drp_low_level]
- ,[fs_qty_for_rental])
- SELECT
- [item]
- ,@whse_B -- Replace the old whse value with the new whse value
- -- Zero out, or set to default values, existing values for the current warehouse
- -- Keep the values for the fields you want to copy over
- ,0 --[qty_on_hand]
- ,0 --[qty_alloc_co]
- ,0 --[alloc_trn]
- ,0 --[qty_trans]
- ,0 --[qty_ordered]
- ,0 --[qty_mrb]
- ,0 --[qty_sold_ytd]
- ,0 --[qty_pur_ytd]
- ,0 --[trn_in_ytd]
- ,0 --[trn_out_ytd]
- ,0 --[qty_reorder]
- ,0 --[sales_ytd]
- ,0 --[sales_ptd]
- ,[cycle_freq]
- ,NULL --[last_cycle]
- ,0 --[cnt_in_proc]
- ,[cycle_flag]
- ,[cycle_type]
- ,0 --[phy_inv_qty]
- ,NULL --[phy_inv_dte]
- ,0 --[qty_wip]
- ,0 --[qty_rsvd_co]
- ,[replen_po_num]
- ,[replen_ps_num]
- ,[replen_trn_num]
- ,0 --[NoteExistsFlag]
- ,NULL --[RecordDate]
- ,NULL --[RowPointer]
- ,NULL --[CreatedBy]
- ,NULL --[UpdatedBy]
- ,NULL --[CreateDate]
- ,0 --[InWorkflow]
- ,1 --[count_sequence]
- ,0 --[last_count_qty_on_hand]
- ,0 --[unit_cost]
- ,0 --[lst_u_cost]
- ,0 --[avg_u_cost]
- ,0 --[asm_setup]
- ,0 --[asm_run]
- ,0 --[asm_matl]
- ,0 --[asm_tool]
- ,0 --[asm_fixture]
- ,0 --[asm_other]
- ,0 --[asm_fixed]
- ,0 --[asm_var]
- ,0 --[asm_outside]
- ,0 --[comp_setup]
- ,0 --[comp_run]
- ,0 --[comp_matl]
- ,0 --[comp_tool]
- ,0 --[comp_fixture]
- ,0 --[comp_other]
- ,0 --[comp_fixed]
- ,0 --[comp_var]
- ,0 --[comp_outside]
- ,0 --[sub_matl]
- ,0 --[cur_u_cost]
- ,0 --[unit_mat_cost]
- ,0 --[unit_duty_cost]
- ,0 --[unit_freight_cost]
- ,0 --[unit_brokerage_cost]
- ,0 --[unit_insurance_cost]
- ,0 --[unit_loc_frt_cost]
- ,0 --[cur_mat_cost]
- ,0 --[cur_duty_cost]
- ,0 --[cur_freight_cost]
- ,0 --[cur_brokerage_cost]
- ,0 --[cur_insurance_cost]
- ,0 --[cur_loc_frt_cost]
- ,0 --[matl_cost]
- ,0 --[lbr_cost]
- ,0 --[fovhd_cost]
- ,0 --[vovhd_cost]
- ,0 --[out_cost]
- ,0 --[cur_matl_cost]
- ,0 --[cur_lbr_cost]
- ,0 --[cur_fovhd_cost]
- ,0 --[cur_vovhd_cost]
- ,0 --[cur_out_cost]
- ,0 --[avg_matl_cost]
- ,0 --[avg_lbr_cost]
- ,0 --[avg_fovhd_cost]
- ,0 --[avg_vovhd_cost]
- ,0 --[avg_out_cost]
- ,0 --[min_consignment_qty]
- ,0 --[max_consignment_qty]
- ,0 --[qty_contained]
- ,NULL --[fs_p_m_t_code]
- ,NULL --[fs_supply_whse]
- ,[fs_vend_num]
- ,[fs_order_min]
- ,[fs_order_max]
- ,[fs_order_mult]
- ,[fs_days_supply]
- ,0 --[fs_consumable]
- ,-1 --[fs_drp_low_level]
- ,0 --fs_qty_for_rental]
- FROM
- [dbo].[itemwhse] (nolock)
- WHERE
- whse = @whse_A; -- Filter for records from the old warehouse
- COMMIT TRANSACTION @CloneItemWarehouse;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement