vw_labours_and_parts_union.sql 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. SET QUOTED_IDENTIFIER ON
  2. GO
  3. SET ANSI_NULLS ON
  4. GO
  5. CREATE VIEW dbo.vw_labours_and_parts_union AS
  6. SELECT
  7. [order_number],
  8. [order_position],
  9. [order_position_line],
  10. [subsidiary],
  11. [is_invoiced],
  12. [invoice_type],
  13. [invoice_number],
  14. [employee_no],
  15. [mechanic_no],
  16. [labour_operation_id],
  17. [is_nominal],
  18. [time_units],
  19. [net_price_in_order],
  20. [rebate_percent],
  21. [goodwill_percent],
  22. [charge_type],
  23. [text_line],
  24. [usage_value],
  25. [negative_flag],
  26. [labour_type],
  27. NULL AS [part_number],
  28. NULL AS [stock_no],
  29. NULL AS [stock_removal_date],
  30. NULL AS [amount],
  31. NULL AS [sum],
  32. NULL AS [parts_type],
  33. [client_db],
  34. 'labours' AS source_table
  35. FROM [LOCOSOFT].[dbo].[labours]
  36. UNION ALL
  37. SELECT
  38. [order_number],
  39. [order_position],
  40. [order_position_line],
  41. [subsidiary],
  42. [is_invoiced],
  43. [invoice_type],
  44. [invoice_number],
  45. [employee_no],
  46. [mechanic_no],
  47. NULL AS [labour_operation_id],
  48. NULL AS [is_nominal],
  49. NULL AS [time_units],
  50. NULL AS [net_price_in_order],
  51. [rebate_percent],
  52. [goodwill_percent],
  53. NULL AS [charge_type],
  54. [text_line],
  55. [usage_value],
  56. NULL AS [negative_flag],
  57. NULL AS [labour_type],
  58. [part_number],
  59. [stock_no],
  60. [stock_removal_date],
  61. [amount],
  62. [sum],
  63. [parts_type],
  64. [client_db],
  65. 'parts' AS source_table
  66. FROM [LOCOSOFT].[dbo].[parts];
  67. GO
  68. SET QUOTED_IDENTIFIER OFF
  69. GO
  70. SET ANSI_NULLS OFF
  71. GO
  72. GO