Advertisement
Guest User

Untitled

a guest
Feb 14th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 5.69 KB | None | 0 0
  1.  
  2. SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
  3. --TOP CORE
  4. ;WITH top_core_counts_cte AS (
  5.  
  6. SELECT collect_schemas_operations_equipments.scoe_whst_wheel_style_part_number, ISNULL(wheel_styles.wheel_style, 'ND') AS 'wheel_style', schemas_operations_equipments.string3, SUM(CAST(collect_schemas_operations_equipments.quantity AS BIGINT)) AS 'Quantity_collect'
  7.  FROM collect_schemas_operations_equipments
  8.                              LEFT JOIN
  9.                              wheel_styles ON collect_schemas_operations_equipments.scoe_whst_wheel_style_part_number = wheel_styles.wheel_style_part_number
  10.                              INNER JOIN
  11.                              schemas_operations_equipments ON collect_schemas_operations_equipments.scoe_schema_number = schemas_operations_equipments.schema_number AND
  12.                              collect_schemas_operations_equipments.scoe_schema_year = schemas_operations_equipments.schema_year
  13. WHERE (collect_schemas_operations_equipments.scoe_operation_key = '015')
  14.             AND (collect_schemas_operations_equipments.scoe_equi_equipment_key <> 'MRB01')
  15.             AND (effective_date < '12/31/2018 23:59:59')
  16.             AND (collect_schemas_operations_equipments.opre_result_id = 'PRO')
  17.             AND (collect_schemas_operations_equipments.scoe_site_key = 'P33')
  18.             --AND (scoe_whst_wheel_style_part_number IN (SELECT * FROM SPLIT(@CastWSPN)) OR @CastWSPN = '-1')
  19.             AND (collect_schemas_operations_equipments.record_status = 'ACT')
  20.     GROUP BY collect_schemas_operations_equipments.scoe_whst_wheel_style_part_number, wheel_styles.wheel_style, schemas_operations_equipments.string3
  21.  
  22. )
  23.  
  24. INSERT INTO shots_wheel_styles_mold_components
  25. SELECT scoe_whst_wheel_style_part_number AS 'wheel_style_part_number', 'T/C' AS 'mold_component_key', string3 AS 'mold_letter', 'ACT' AS 'status', Quantity_collect AS 'quantity', '12/31/2018 23:59:59' as 'period', dbo.ufn_GetSite() AS 'site_key','cramirez' AS 'created_by', GETDATE() AS 'created_on', 'cramirez' AS 'modified_by', GETDATE() AS 'modified_on'
  26. FROM top_core_counts_cte
  27.  
  28. -- SIDE CORE
  29.  
  30. ;WITH top_core_counts_cte AS (
  31.  
  32. SELECT collect_schemas_operations_equipments.scoe_whst_wheel_style_part_number, ISNULL(wheel_styles.wheel_style, 'ND') AS 'wheel_style', schemas_operations_equipments.string2, SUM(CAST(collect_schemas_operations_equipments.quantity AS BIGINT)) AS 'Quantity_collect'
  33.  FROM collect_schemas_operations_equipments
  34.                              LEFT JOIN
  35.                              wheel_styles ON collect_schemas_operations_equipments.scoe_whst_wheel_style_part_number = wheel_styles.wheel_style_part_number
  36.                              INNER JOIN
  37.                              schemas_operations_equipments ON collect_schemas_operations_equipments.scoe_schema_number = schemas_operations_equipments.schema_number AND
  38.                              collect_schemas_operations_equipments.scoe_schema_year = schemas_operations_equipments.schema_year
  39. WHERE (collect_schemas_operations_equipments.scoe_operation_key = '015')
  40.             AND (collect_schemas_operations_equipments.scoe_equi_equipment_key <> 'MRB01')
  41.             AND (effective_date < '12/31/2018 23:59:59')
  42.             AND (collect_schemas_operations_equipments.opre_result_id = 'PRO')
  43.             AND (collect_schemas_operations_equipments.scoe_site_key = 'P33')
  44.             --AND (scoe_whst_wheel_style_part_number IN (SELECT * FROM SPLIT(@CastWSPN)) OR @CastWSPN = '-1')
  45.             AND (collect_schemas_operations_equipments.record_status = 'ACT')
  46.     GROUP BY collect_schemas_operations_equipments.scoe_whst_wheel_style_part_number, wheel_styles.wheel_style, schemas_operations_equipments.string2
  47.  
  48. )
  49.  
  50. INSERT INTO shots_wheel_styles_mold_components
  51. SELECT scoe_whst_wheel_style_part_number AS 'wheel_style_part_number', 'F/C' AS 'mold_component_key', string2 AS 'mold_letter', 'ACT' AS 'status', Quantity_collect AS 'quantity', '12/31/2018 23:59:59' as 'period', dbo.ufn_GetSite() AS 'site_key', 'cramirez' AS 'created_by', GETDATE() AS 'created_on', 'cramirez' AS 'modified_by', GETDATE() AS 'modified_on'
  52. FROM top_core_counts_cte
  53.  
  54. -- FACE CORE
  55.  
  56. ;WITH top_core_counts_cte AS (
  57.  
  58.  
  59. SELECT collect_schemas_operations_equipments.scoe_whst_wheel_style_part_number, ISNULL(wheel_styles.wheel_style, 'ND') AS 'wheel_style', schemas_operations_equipments.string1, SUM(CAST(collect_schemas_operations_equipments.quantity AS BIGINT)) AS 'Quantity_collect'
  60.  FROM collect_schemas_operations_equipments
  61.                              LEFT JOIN
  62.                              wheel_styles ON collect_schemas_operations_equipments.scoe_whst_wheel_style_part_number = wheel_styles.wheel_style_part_number
  63.                              INNER JOIN
  64.                              schemas_operations_equipments ON collect_schemas_operations_equipments.scoe_schema_number = schemas_operations_equipments.schema_number AND
  65.                              collect_schemas_operations_equipments.scoe_schema_year = schemas_operations_equipments.schema_year
  66. WHERE (collect_schemas_operations_equipments.scoe_operation_key = '015')
  67.             AND (collect_schemas_operations_equipments.scoe_equi_equipment_key <> 'MRB01')
  68.             AND (effective_date < '12/31/2018 23:59:59')
  69.             AND (collect_schemas_operations_equipments.opre_result_id = 'PRO')
  70.             AND (collect_schemas_operations_equipments.scoe_site_key = 'P33')
  71.             --AND (scoe_whst_wheel_style_part_number IN (SELECT * FROM SPLIT(@CastWSPN)) OR @CastWSPN = '-1')
  72.             AND (collect_schemas_operations_equipments.record_status = 'ACT')
  73.     GROUP BY collect_schemas_operations_equipments.scoe_whst_wheel_style_part_number, wheel_styles.wheel_style, schemas_operations_equipments.string1
  74.  
  75. )
  76.  
  77. INSERT INTO shots_wheel_styles_mold_components
  78. SELECT scoe_whst_wheel_style_part_number AS 'wheel_style_part_number', 'F/C' AS 'mold_component_key', string1 AS 'mold_letter', 'ACT' AS 'status', Quantity_collect AS 'quantity', '12/31/2018 23:59:59' as 'period', dbo.ufn_GetSite() AS 'site_key', 'cramirez' AS 'created_by', GETDATE() AS 'created_on', 'cramirez' AS 'modified_by', GETDATE() AS 'modified_on'
  79. FROM top_core_counts_cte
  80.  
  81. SET TRANSACTION ISOLATION LEVEL READ COMMITTED
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement