	--VendorSettingsTypes
	DECLARE @VendorSettingsTypes TABLE (RowId uniqueidentifier NOT NULL,[Name] [nvarchar](500) NOT NULL,SettingsType int NOT NULL);

	INSERT into @VendorSettingsTypes (RowId, [Name], SettingsType) VALUES ('28C71D1B-C5BA-4BC0-8EC3-B18DAB4E07CB', N'MsisdnRequired',3);

	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 @MsisdnRequiredId int
	select @MsisdnRequiredId = Id from VendorSettingsTypes where RowId='28C71D1B-C5BA-4BC0-8EC3-B18DAB4E07CB'
	--Add to ALL vendors
	INSERT into @VendorSettings select VendorTbl.VendorId,@MsisdnRequiredId,'false' 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.*;

	 