USE [ID2Manager] GO /****** Object: UserDefinedFunction [dbo].[MarkupDataParse] Script Date: 2023-08-16 ���� 1:20:32 ******/ DROP FUNCTION [dbo].[MarkupDataParse] GO /****** Object: UserDefinedFunction [dbo].[MarkupDataParse] Script Date: 2023-08-16 ���� 1:20:32 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: -- Create date: -- Description: -- ============================================= CREATE FUNCTION [dbo].[MarkupDataParse] ( -- Add the parameters for the function here @MARKUP_DATA VARCHAR(MAX) ) RETURNS VARCHAR(MAX) AS BEGIN -- Declare the return variable here DECLARE @RESULT_VALUE VARCHAR(MAX) DECLARE @DECOMPRESS_DATA VARCHAR(MAX) SET @DECOMPRESS_DATA = CONVERT(varchar(max), CONVERT(xml, decompress(CAST(REPLACE(@MARKUP_DATA,'|DZ|','') as xml).value('xs:base64Binary(.)', 'varbinary(max)')))) IF JSON_VALUE(@DECOMPRESS_DATA, '$.Text') IS NOT NULL SET @RESULT_VALUE = JSON_VALUE(@DECOMPRESS_DATA, '$.Text') ELSE IF JSON_VALUE(@DECOMPRESS_DATA, '$.ArrowText') IS NOT NULL SET @RESULT_VALUE = JSON_VALUE(@DECOMPRESS_DATA, '$.ArrowText') ELSE SET @RESULT_VALUE = NULL -- Return the result of the function RETURN @RESULT_VALUE END GO