SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO
CREATE VIEW [xtract].[labours_and_parts_union] AS
SELECT [order_number]
     , [order_position]
     , [order_position_line]
     , [subsidiary]
     , [is_invoiced]
     , [invoice_type]
     , [invoice_number]
     , [employee_no]
     , [mechanic_no]
     , [labour_operation_id]
     , [is_nominal]
     , [time_units]
     , [net_price_in_order]
     , [rebate_percent]
     , [goodwill_percent]
     , [charge_type]
     , [text_line]
     , [usage_value]
     , [negative_flag]
     , [labour_type]
     , NULL AS [part_number]
     , NULL AS [stock_no]
     , NULL AS [stock_removal_date]
     , NULL AS [amount]
     , NULL AS [sum]
     , NULL AS [parts_type]
     , [client_db]
     , 'labours' AS [source_table]
FROM [LOCOSOFT].[dbo].[labours]

UNION ALL

SELECT [order_number]
     , [order_position]
     , [order_position_line]
     , [subsidiary]
     , [is_invoiced]
     , [invoice_type]
     , [invoice_number]
     , [employee_no]
     , [mechanic_no]
     , NULL AS [labour_operation_id]
     , NULL AS [is_nominal]
     , NULL AS [time_units]
     , NULL AS [net_price_in_order]
     , [rebate_percent]
     , [goodwill_percent]
     , NULL AS [charge_type]
     , [text_line]
     , [usage_value]
     , NULL AS [negative_flag]
     , NULL AS [labour_type]
     , [part_number]
     , [stock_no]
     , [stock_removal_date]
     , [amount]
     , [sum]
     , [parts_type]
     , [client_db]
     , 'parts' AS [source_table]
FROM [LOCOSOFT].[dbo].[parts]
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

GO
