	
	--VendorSettingsTypes
   DECLARE @VendorSettingsTypes TABLE (RowId uniqueidentifier NOT NULL,[Name] [nvarchar](500) NOT NULL,SettingsType int NOT NULL);
    
	INSERT into @VendorSettingsTypes (RowId, [Name], SettingsType) VALUES ('F1E571EB-D64C-4A68-980D-68CD99AC7687', N'ConfigurationProtectedEnabled',1);

	INSERT into @VendorSettingsTypes (RowId, [Name], SettingsType) VALUES ('06ECA359-8C47-4849-BD57-0B1ADD2B2EEF', N'ConfigurationProtectedRetryCount',1);
	

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

	--VendorSettings
	DECLARE @VendorSettings TABLE (VendorId int NOT NULL, SettingTypeId int NOT NULL, Value nvarchar(1024) NULL);

	--Get the settings DB Id
	declare @ConfigurationProtectedEnabledId int

	declare @ConfigurationProtectedRetryCountId int

	select @ConfigurationProtectedEnabledId = Id from VendorSettingsTypes where RowId='F1E571EB-D64C-4A68-980D-68CD99AC7687'

	select @ConfigurationProtectedRetryCountId = Id from VendorSettingsTypes where RowId='06ECA359-8C47-4849-BD57-0B1ADD2B2EEF'

	--Add to ALL vendors
	INSERT into @VendorSettings select VendorTbl.VendorId,@ConfigurationProtectedEnabledId,'false' from VendorTbl order by VendorId
	INSERT into @VendorSettings select VendorTbl.VendorId,@ConfigurationProtectedRetryCountId,'3' from VendorTbl order by VendorId

	MERGE INTO dbo.[VendorSettings] AS TARGET  
		USING @VendorSettings AS SOURCE  
		ON TARGET.VendorId = SOURCE.VendorId and TARGET.SettingTypeId = SOURCE.SettingTypeId	
		WHEN MATCHED THEN    
			UPDATE SET	[Value] = SOURCE.[Value],
						[UpdatedUtc] = GetUtcDate()
		WHEN NOT MATCHED BY TARGET THEN   
			INSERT (VendorId, SettingTypeId, [Value],CreatedUtc,UpdatedUtc) VALUES (SOURCE.VendorId, SOURCE.SettingTypeId, SOURCE.[Value],GetUtcDate(),GetUtcDate())  
	OUTPUT $action, SOURCE.*;

