
<cfquery datasource="#application.config.DSN#">
UPDATE [Person] SET
	[Picture] = (CASE WHEN CHARINDEX('/',[Picture]) = 0 AND ([Picture] != '' AND [Picture] != 'PL_blankpic.jpg') THEN [Picture]
					WHEN [Picture] = '' THEN CAST(NULL As nvarchar(250))
					WHEN CHARINDEX('/',[Picture]) > 0 AND RIGHT([Picture], (CHARINDEX('/', REVERSE([Picture])) -1)) = 'PL_blankpic.jpg' THEN CAST(NULL As nvarchar(250))
					WHEN CHARINDEX('/',[Picture]) = 0 AND [Picture] = 'PL_blankpic.jpg' THEN CAST(NULL As nvarchar(250))
					ELSE RIGHT([Picture], (CHARINDEX('/', REVERSE([Picture])) -1))
				END)
</cfquery>

<cfquery name="qryAppSettings" datasource="#application.config.DSN#">
IF NOT EXISTS(SELECT *
FROM AppSetting
WHERE Name = 'REACHTENANT')
BEGIN
      INSERT INTO [dbo].[AppSetting]
            ([Name]
            ,[Value])
      VALUES
            ('REACHTENANT'
            , '')
END

IF NOT EXISTS(SELECT *
FROM AppSetting
WHERE Name = 'REACHAUDIENCE')
BEGIN
      INSERT INTO [dbo].[AppSetting]
            ([Name]
            ,[Value])
      VALUES
            ('REACHAUDIENCE'
            , 'https://icreach.app/api/v1')
END

IF NOT EXISTS(SELECT *
FROM AppSetting
WHERE Name = 'REACHAUTHORITY')
BEGIN
      INSERT INTO [dbo].[AppSetting]
            ([Name]
            ,[Value])
      VALUES
            ('REACHAUTHORITY'
            , '')
END

IF NOT EXISTS(SELECT *
FROM AppSetting
WHERE Name = 'REACHCLIENTID')
BEGIN
      INSERT INTO [dbo].[AppSetting]
            ([Name]
            ,[Value])
      VALUES
            ('REACHCLIENTID'
            , '')
END

IF NOT EXISTS(SELECT *
FROM AppSetting
WHERE Name = 'REACHCLIENTSECRET')
BEGIN
      INSERT INTO [dbo].[AppSetting]
            ([Name]
            ,[Value])
      VALUES
            ('REACHCLIENTSECRET'
            , '')
END
</cfquery>