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

	INSERT into @VendorSettingsTypes (RowId, [Name], SettingsType) VALUES ('E4DF52D0-4F8D-45A8-9962-9B6D318B85A9', N'MFAEnabled',1);
	INSERT into @VendorSettingsTypes (RowId, [Name], SettingsType) VALUES ('c581d9ac-7f85-4429-b8a4-334ca50f0cce', N'MfaAuthTempTokenExpireInMinutes',3);
	INSERT into @VendorSettingsTypes (RowId, [Name], SettingsType) VALUES ('89BCB559-66B0-422E-A724-20FE6B46A0BA', N'TwilioMFAUserName',3);
	INSERT into @VendorSettingsTypes (RowId, [Name], SettingsType) VALUES ('D05AD662-7EF8-4C6C-8AB7-E920533666F3', N'TwilioMFAPassword',3);
	INSERT into @VendorSettingsTypes (RowId, [Name], SettingsType) VALUES ('808CB744-8357-4662-81E8-816AA9E5A2DB', N'TwilioMFAServiceSID',3);
	INSERT into @VendorSettingsTypes (RowId, [Name], SettingsType) VALUES ('61F6A9BF-AEB2-4FF8-B3ED-1AC27281BF1C', N'MFAMaxRetry',3);
	INSERT into @VendorSettingsTypes (RowId, [Name], SettingsType) VALUES ('BC514E6A-E62A-4596-92C5-D9ACA66F2CD1', N'MFAWaitingIntervalInSeconds',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 @MFAEnabledId int

	select @MFAEnabledId = Id from VendorSettingsTypes where RowId='E4DF52D0-4F8D-45A8-9962-9B6D318B85A9'

	declare @MfaAuthTempTokenExpireInMinutesId int

	select @MfaAuthTempTokenExpireInMinutesId = Id from VendorSettingsTypes where RowId='c581d9ac-7f85-4429-b8a4-334ca50f0cce'

	declare @MFAMaxRetryId int

	select @MFAMaxRetryId = Id from VendorSettingsTypes where RowId='61F6A9BF-AEB2-4FF8-B3ED-1AC27281BF1C'

	declare @MFAWaitingIntervalInSecondsId int

	select @MFAWaitingIntervalInSecondsId = Id from VendorSettingsTypes where RowId='BC514E6A-E62A-4596-92C5-D9ACA66F2CD1'

	--Add to ALL vendors
	INSERT into @VendorSettings select VendorTbl.VendorId,@MFAEnabledId,'{ "mfa": {"enabled": false, "methods": { "sms": "true", "email": "true"  }, "defaultUser":true, "defaultMethod":"sms"}}' from VendorTbl order by VendorId
	INSERT into @VendorSettings select VendorTbl.VendorId,@MfaAuthTempTokenExpireInMinutesId,'10' from VendorTbl order by VendorId
	INSERT into @VendorSettings select VendorTbl.VendorId,@MFAMaxRetryId,'3' from VendorTbl order by VendorId
	INSERT into @VendorSettings select VendorTbl.VendorId,@MFAWaitingIntervalInSecondsId,'60' 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.*;

	 