Removing HTML tags from Sql String
create function dbo.StripHTML(
@text varchar(max)
)
returns varchar(max) as begin
declare @textXML xml
declare @result varchar(max)
set @textXML = @text;
with doc(contents) as
(
select chunks.chunk.query('.') from @textXML.nodes('/') as chunks(chunk)
)
select @result = contents.value('.', 'varchar(max)') from doc
return @result
end
go
Now execute -
select dbo.StripHTML('Big Size Buckle Halter Neck Vests Tops ')
@text varchar(max)
)
returns varchar(max) as begin
declare @textXML xml
declare @result varchar(max)
set @textXML = @text;
with doc(contents) as
(
select chunks.chunk.query('.') from @textXML.nodes('/') as chunks(chunk)
)
select @result = contents.value('.', 'varchar(max)') from doc
return @result
end
go
Now execute -
select dbo.StripHTML('
Comments
Post a Comment