	
	-- 01. Add rows to [dbo].[DeviceTypes]
	DECLARE @DeviceTypes TABLE ([Id] INT NOT NULL, [Name] NVARCHAR(50) NULL);
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES (0,N'ESI_CONTROLLER')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES (1,N'GENERIC_TYPE_GENERIC_CONTROLLER')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES (2,N'GENERIC_TYPE_STATIC_CONTROLLER')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES (3,N'GENERIC_TYPE_AV_CONTROL_POINT')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES (4,N'GENERIC_TYPE_DISPLAY')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES (8,N'GENERIC_TYPE_THERMOSTAT')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES (9,N'GENERIC_TYPE_WINDOW_COVERING')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES (15, N'GENERIC_TYPE_REPEATER_SLAVE')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES (16, N'GENERIC_TYPE_SWITCH_BINARY')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES (17, N'GENERIC_TYPE_SWITCH_MULTILEVEL')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES (18, N'GENERIC_TYPE_SWITCH_REMOTE')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES (19, N'GENERIC_TYPE_SWITCH_TOGGLE')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES (20, N'GENERIC_TYPE_ZIP_GATEWAY')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES (21, N'GENERIC_TYPE_ZIP_NODE')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES (22, N'GENERIC_TYPE_VENTILATION')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES ( 23, N'GENERIC_TYPE_SECURITY_PANEL')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES ( 32, N'GENERIC_TYPE_SENSOR_BINARY')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES ( 33, N'GENERIC_TYPE_SENSOR_MULTILEVEL')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES ( 48, N'GENERIC_TYPE_METER_PULSE')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES ( 49, N'GENERIC_TYPE_METER')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES ( 64, N'GENERIC_TYPE_ENTRY_CONTROL')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES ( 80, N'GENERIC_TYPE_SEMI_INTEROPERABLE')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES ( 161 , N'GENERIC_TYPE_SENSOR_ALARM')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES ( 234 , N'GENERIC_TYPE_ZWAVEPLUS_RANGE_A')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES ( 235 , N'GENERIC_TYPE_ZWAVEPLUS_RANGE_B')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES ( 236 , N'GENERIC_TYPE_ZWAVEPLUS_RANGE_C')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES ( 237 , N'GENERIC_TYPE_ZWAVEPLUS_RANGE_D')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES ( 238 , N'GENERIC_TYPE_ZWAVEPLUS_RANGE_E')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES ( 239 , N'GENERIC_TYPE_ZWAVEPLUS_RANGE_F')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES ( 255 , N'GENERIC_TYPE_NON_INTEROPERABLE')
	INSERT INTO @DeviceTypes ([Id], [Name])  VALUES ( 206 , N'IP_CAMERA')
	
	MERGE INTO dbo.[DeviceTypes] AS TARGET
	USING @DeviceTypes AS SOURCE  
	ON TARGET.Id = SOURCE.Id  
	WHEN MATCHED THEN
	UPDATE SET 
			[Id] = SOURCE.[Id],
			[Name] = SOURCE.[Name]
	WHEN NOT MATCHED BY TARGET THEN   
	INSERT ( [Id], [Name])   
	VALUES ( SOURCE.[Id], SOURCE.[Name])  
	OUTPUT $action, SOURCE.*;
	
	
	
	
	--02. Add rows to [dbo].[CD_RSU_Customers]
	DECLARE @CD_RSU_Customers TABLE ([Customer_Id] INT NOT NULL, [Customer_Name] NVARCHAR(50) NOT NULL, [Notification_Emails] NVARCHAR(max) NULL);
	INSERT INTO @CD_RSU_Customers ([Customer_Id], [Customer_Name], [Notification_Emails]) VALUES ( 1, N'Elkotek',N'shimonki@essence-grp.com')
	INSERT INTO @CD_RSU_Customers ([Customer_Id], [Customer_Name], [Notification_Emails]) VALUES ( 2, N'Ritar',N'shimonki@essence-grp.com')
	INSERT INTO @CD_RSU_Customers ([Customer_Id], [Customer_Name], [Notification_Emails]) VALUES ( 3, N'Generic',N'shimonki@essence-grp.com')


	MERGE INTO dbo.[CD_RSU_Customers] AS TARGET
	USING @CD_RSU_Customers AS SOURCE  
	ON TARGET.Customer_Id = SOURCE.Customer_Id  
	WHEN MATCHED THEN
	UPDATE SET 
			[Customer_Id] = SOURCE.[Customer_Id],
			[Notification_Emails] = SOURCE.[Notification_Emails]
	WHEN NOT MATCHED BY TARGET THEN   
	INSERT ( [Customer_Id], [Customer_Name], [Notification_Emails])   
	VALUES ( SOURCE.[Customer_Id], SOURCE.[Customer_Name], SOURCE.[Notification_Emails])  
	OUTPUT $action, SOURCE.*;
	
	
	--03. Add rows to [dbo].[CD_Currency]
	DECLARE @CD_Currency TABLE ([ID] SMALLINT NOT NULL, [Culture] NVARCHAR(5) NOT NULL, [Description] NVARCHAR(50) NULL);
	INSERT INTO @CD_Currency ([ID], [Culture], [Description]) VALUES (0, N'en-US', N'USD - United States dollar')
	INSERT INTO @CD_Currency ([ID], [Culture], [Description]) VALUES (1, N'de-DE', N'EUR - European euro')
	INSERT INTO @CD_Currency ([ID], [Culture], [Description]) VALUES (2, N'en-GB', N'GBP - British pound')
	INSERT INTO @CD_Currency ([ID], [Culture], [Description]) VALUES (3, N'en-AU', N'AUD - Australian dollar')
	INSERT INTO @CD_Currency ([ID], [Culture], [Description]) VALUES (4, N'en-CA', N'CAD - Canadian dollar')
	INSERT INTO @CD_Currency ([ID], [Culture], [Description]) VALUES (5, N'nl-NL', N'ANG - Netherlands Antillean gulden')
	INSERT INTO @CD_Currency ([ID], [Culture], [Description]) VALUES (6, N'he-IL', N'ILS - Israeli new sheqel')
	INSERT INTO @CD_Currency ([ID], [Culture], [Description]) VALUES (7, N'es-MX', N'MXN - Mexican peso')
	INSERT INTO @CD_Currency ([ID], [Culture], [Description]) VALUES (8, N'pl-PL', N'PLN - Polish zloty')
	INSERT INTO @CD_Currency ([ID], [Culture], [Description]) VALUES (9, N'ru-RU', N'RUB - Russian ruble')
	INSERT INTO @CD_Currency ([ID], [Culture], [Description]) VALUES (10, N'sv-SE', N'SEK - Swedish krona')
	INSERT INTO @CD_Currency ([ID], [Culture], [Description]) VALUES (11, N'af-ZA', N'ZAR - South African rand')
	INSERT INTO @CD_Currency ([ID], [Culture], [Description]) VALUES (12, N'hi-IN', N'INR - Indian rupee')
	INSERT INTO @CD_Currency ([ID], [Culture], [Description]) VALUES (13, N'zh-HK', N'HKD - Hong Kong dollar')

	MERGE INTO dbo.[CD_Currency] AS TARGET
	USING @CD_Currency AS SOURCE  
	ON TARGET.ID = SOURCE.ID  
	WHEN MATCHED THEN
	UPDATE SET 
			[Culture] = SOURCE.[Culture],
			[Description] = SOURCE.[Description]
	WHEN NOT MATCHED BY TARGET THEN   
	INSERT ([ID], [Culture], [Description])   
	VALUES (SOURCE.[ID], SOURCE.[Culture], SOURCE.[Description])  
	OUTPUT $action, SOURCE.*;
	
	
	--04. Add rows to [dbo].[CD_Arm_Forced_State]
	DECLARE @CD_Arm_Forced_State TABLE (Arm_Forced_State_Code TINYINT NOT NULL, [Description] VARCHAR(100) NOT NULL);
	INSERT INTO @CD_Arm_Forced_State ([Arm_Forced_State_Code], [Description]) VALUES (0, 'Forced')
	INSERT INTO @CD_Arm_Forced_State ([Arm_Forced_State_Code], [Description]) VALUES (1, 'Not Forced')
	INSERT INTO @CD_Arm_Forced_State ([Arm_Forced_State_Code], [Description]) VALUES (2, 'Forced with Device Bypass')

	MERGE INTO dbo.[CD_Arm_Forced_State] AS TARGET
	USING @CD_Arm_Forced_State AS SOURCE  
	ON TARGET.Arm_Forced_State_Code = SOURCE.Arm_Forced_State_Code  
	WHEN MATCHED THEN
	UPDATE SET [Description] = SOURCE.[Description]
	WHEN NOT MATCHED BY TARGET THEN   
	INSERT (Arm_Forced_State_Code, [Description])   
	VALUES (SOURCE.Arm_Forced_State_Code, SOURCE.[Description])  
	OUTPUT $action, SOURCE.*;
	
	--05. Add rows to [dbo].[CD_Arm_Type]
	DECLARE @CD_Arm_Type TABLE (Arm_Type TINYINT NOT NULL, [Description] VARCHAR(100) NOT NULL);

	INSERT INTO @CD_Arm_Type ([Arm_Type], [Description]) VALUES (0, 'Total (Full) Arm')
	INSERT INTO @CD_Arm_Type ([Arm_Type], [Description]) VALUES (1, 'Part Arm')
	INSERT INTO @CD_Arm_Type ([Arm_Type], [Description]) VALUES (2, 'Perimeter Arm')
	INSERT INTO @CD_Arm_Type ([Arm_Type], [Description]) VALUES (3, 'Disarmed')
	INSERT INTO @CD_Arm_Type ([Arm_Type], [Description]) VALUES (4, 'Total and Perimeter Arm')
	INSERT INTO @CD_Arm_Type ([Arm_Type], [Description]) VALUES (5, 'Part and Perimeter Arm')

	MERGE INTO dbo.[CD_Arm_Type] AS TARGET  
	USING @CD_Arm_Type AS SOURCE  
	ON TARGET.Arm_Type = SOURCE.Arm_Type  
	WHEN MATCHED THEN    
	UPDATE SET [Description] = SOURCE.[Description]
	WHEN NOT MATCHED BY TARGET THEN   
	INSERT (Arm_Type, [Description])   
	VALUES (SOURCE.Arm_Type, SOURCE.[Description])  
	OUTPUT $action, SOURCE.*;
	
	--06. Add rows to [dbo].[CD_Binary_File_Type]
	DECLARE @CD_Binary_File_Type TABLE (File_Type_Code TINYINT NOT NULL, [File_Type_Description] VARCHAR(50) NOT NULL);

	INSERT INTO @CD_Binary_File_Type ([File_Type_Code], [File_Type_Description]) VALUES (0, 'Picture')
	INSERT INTO @CD_Binary_File_Type ([File_Type_Code], [File_Type_Description]) VALUES (1, 'Video')
	INSERT INTO @CD_Binary_File_Type ([File_Type_Code], [File_Type_Description]) VALUES (2, 'Device Table')

	MERGE INTO dbo.[CD_Binary_File_Type] AS TARGET  
	USING @CD_Binary_File_Type AS SOURCE  
	ON TARGET.File_Type_Code = SOURCE.File_Type_Code  
	WHEN MATCHED THEN    
	UPDATE SET [File_Type_Description] = SOURCE.[File_Type_Description]
	WHEN NOT MATCHED BY TARGET THEN   
	INSERT ([File_Type_Code], [File_Type_Description])   
	VALUES (SOURCE.[File_Type_Code], SOURCE.[File_Type_Description])  
	OUTPUT $action, SOURCE.*;

