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

	INSERT into @UserSettingsTypes (RowId, [Name], SettingsType) VALUES ('54640A2C-C9E9-46CD-BFE9-BEE5EFF7F0DD', N'AiChatHistoryDays',3);

	INSERT into @UserSettingsTypes (RowId, [Name], SettingsType) VALUES ('2C071EC3-EDDE-4120-B8EA-2AEA3E8EE95F', N'AiChatHistoryPrompts',3);
	

	MERGE INTO dbo.[UserSettingsTypes] AS TARGET  
		USING @UserSettingsTypes 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.*;

 --   --Get the settings DB Id
 --   declare @AiChatHistoryDays int;
 --   declare @AiChatHistoryPrompts int;

 --   select @AiChatHistoryDays = Id from [UserSettingsTypes] where RowId='54640A2C-C9E9-46CD-BFE9-BEE5EFF7F0DD';
 --   select @AiChatHistoryPrompts = Id from [UserSettingsTypes] where RowId='2C071EC3-EDDE-4120-B8EA-2AEA3E8EE95F';

 --   --Add to ALL existing users
 --   declare @userSettings table ([CmsUserId] [int] NOT NULL, [SettingTypeId] [int] NOT NULL, [Value] [nvarchar](1024) NOT NULL);
 --   INSERT into @userSettings select cmuserid,@AiChatHistoryDays,'7' from cmsusertbl where securitylevelid<3;
 --   INSERT into @userSettings select cmuserid,@AiChatHistoryPrompts,'20' from cmsusertbl where securitylevelid<3;


	--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.*;