Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mejoras al código de strip_tags para SQL Server

Status
Not open for further replies.

mauroardolino

Programmer
Apr 7, 2016
1
AR
thread183-880068

Better code, corrected:

create function dbo.strip_tags( @s varchar(5000) )
returns varchar(5000) as
begin
declare @pos1 smallint, @pos2 smallint, @largo smallint
set @pos2 = 1

while @pos2 > 0
begin
set @pos1 = charindex('<', @s, @pos2)
set @pos2 = charindex('>', @s, @pos1+1)
if @pos1 = 0 or @pos2 = 0 break

set @largo=LEN(@s)
set @s = left(@s, @pos1-1) + right(@s, len(@s)-@pos2)
set @largo=@largo-LEN(@s)

set @pos2 = @pos2-@largo
end


return @s
end
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top