/****** Object: UserDefinedFunction [dbo].[Panatrack_ParseData] Script Date: 8/8/2022 1:51:50 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[Panatrack_ParseData]
(
@Input VARCHAR(8000),
@TagName VARCHAR(30)
)
RETURNS VARCHAR(8000)
AS BEGIN
DECLARE @dataStartPos INT
DECLARE @dataEndPos INT
DECLARE @dataLength INT
DECLARE @result VARCHAR(1000)
DECLARE @startTag VARCHAR(30)
DECLARE @endTag VARCHAR(30)
SET @startTag = '[' + @TagName + ']'
SET @endTag = '[/' + @TagName + ']'
SET @dataStartPos = CHARINDEX(@startTag, @Input)
SET @dataLength = CHARINDEX(@endTag, @Input) - (@dataStartPos + LEN(@startTag))
IF @dataStartPos = 0
SET @result = ''
ELSE
BEGIN
SET @result = SUBSTRING(@Input, (@dataStartPos + LEN(@startTag)), @dataLength)
END
RETURN @result
END
GO
Knowledge Base
PanatrackerGP
Was this helpful?