Files
DP44/DataPRO/Modules/Database/DatabaseMigrationScripts/MigrationScripts/Version95/TSRAIRUserDefaults/dbo.UserProperties_DownloadAll.sql
2026-04-17 14:55:32 -04:00

30 lines
988 B
Transact-SQL

DECLARE @UserId INT
DECLARE @PropertyId INT
DECLARE @PropertyValue [NVARCHAR] (MAX)
SELECT @UserId = ID FROM Users WHERE UserName = 'TSRAIRUser'
IF (@UserId IS NOT NULL)
BEGIN
SELECT @PropertyId = PropertyId FROM [dbo].[DefaultProperties] WHERE PropertyName = 'DefaultDownloadAll'
IF (@PropertyId IS NULL)
BEGIN
INSERT INTO [dbo].[DefaultProperties] (PropertyName, DefaultValue) VALUES ('DefaultDownloadAll', 'False')
SELECT @PropertyId = PropertyId FROM [dbo].[DefaultProperties] WHERE PropertyName = 'DefaultDownloadAll'
END
IF (@PropertyId IS NOT NULL)
BEGIN
SELECT @PropertyValue = PropertyValue FROM [dbo].[UserProperties] WHERE UserId = @UserId AND PropertyId = @PropertyId
IF (@PropertyValue IS NULL)
BEGIN
INSERT INTO [dbo].[UserProperties] VALUES (@UserId, @PropertyId, 'True')
END
ELSE
BEGIN
UPDATE [dbo].[UserProperties] SET PropertyValue = 'True' WHERE UserId = @UserId AND PropertyId = @PropertyId;
END
END
END