This query -
DECLARE @Note varchar(255)
SELECT @Note = NoteText
FROM Notes
WHERE RecordID=5173
Returns the following string:
Please review and provide feedback.<br><br><a href=test>Candidate cjtest54r jtest54r</a><br><br><a href=test>Candidate cjtest08r jtest08r</a><br><br>
I use the following commands to parse out the text:
IF (charindex ('<a', @Note, 0)) > 0
BEGIN
DECLARE @URLstart int
SET @URLstart = charindex('<a', @Note, 0)
DECLARE @URLend int
SET @URLend = charindex('>', @Note, @URLstart)
DECLARE @Part1 varchar(255)
SELECT @Part1 = substring(@Note, 1, (@URLstart - 1) )
DECLARE @Part2 varchar(255)
SELECT @Part2 = substring(@Note, (@URLend + 1), len(@Note))
SET @Part2 = substring (@Part2, 1, (charindex('</a>', @Part2, 0)) - 1)
SET @Note = @Part1 + @Part2
IF (charindex ('<a', @Note, @URLend))>0
BEGIN
SELECT 'test'
END
END
SELECT @Note
The result is this:
Please review and provide feedback.<br><br>Candidate cjtest54r jtest54r
However, I need the results to return this:
Please review and provide feedback.<br><br>Candidate cjtest54r jtest54r<br><br>Candidate cjtest08r jtest08r
The query only returns the first Candidate, I need the results to return all of the Candidates in the string, and the number of candidates is not static. In other words there can be from 1 to an infinite (theoretically)number of candidates in any given string.
Any help would be appreciated.
DECLARE @Note varchar(255)
SELECT @Note = NoteText
FROM Notes
WHERE RecordID=5173
Returns the following string:
Please review and provide feedback.<br><br><a href=test>Candidate cjtest54r jtest54r</a><br><br><a href=test>Candidate cjtest08r jtest08r</a><br><br>
I use the following commands to parse out the text:
IF (charindex ('<a', @Note, 0)) > 0
BEGIN
DECLARE @URLstart int
SET @URLstart = charindex('<a', @Note, 0)
DECLARE @URLend int
SET @URLend = charindex('>', @Note, @URLstart)
DECLARE @Part1 varchar(255)
SELECT @Part1 = substring(@Note, 1, (@URLstart - 1) )
DECLARE @Part2 varchar(255)
SELECT @Part2 = substring(@Note, (@URLend + 1), len(@Note))
SET @Part2 = substring (@Part2, 1, (charindex('</a>', @Part2, 0)) - 1)
SET @Note = @Part1 + @Part2
IF (charindex ('<a', @Note, @URLend))>0
BEGIN
SELECT 'test'
END
END
SELECT @Note
The result is this:
Please review and provide feedback.<br><br>Candidate cjtest54r jtest54r
However, I need the results to return this:
Please review and provide feedback.<br><br>Candidate cjtest54r jtest54r<br><br>Candidate cjtest08r jtest08r
The query only returns the first Candidate, I need the results to return all of the Candidates in the string, and the number of candidates is not static. In other words there can be from 1 to an infinite (theoretically)number of candidates in any given string.
Any help would be appreciated.