Search
 
SCRIPT & CODE EXAMPLE
 

SQL

convert html to plain text in sql server

-- select [dbo].[fn_ConvertToTextByHtml] ('<p>I love my country</p>')

CREATE FUNCTION [dbo].[fn_ConvertToTextByHtml] (@HTMLText VARCHAR(MAX))    
RETURNS VARCHAR(MAX)    
AS    
BEGIN    
DECLARE @Start INT    
DECLARE @End INT    
DECLARE @Length INT    
SET @Start = CHARINDEX('<',@HTMLText) SET @End =     
CHARINDEX('>',@HTMLText,CHARINDEX('<',@HTMLText))     
SET @Length = (@End - @Start) + 1 WHILE @Start > 0    
AND @End > 0    
AND @Length > 0    
BEGIN    
SET @HTMLText = STUFF(@HTMLText,@Start,@Length,'')    
SET @Start = CHARINDEX('<',@HTMLText) SET @End = CHARINDEX('>',@HTMLText,CHARINDEX('<',@HTMLText))    
SET @Length = (@End - @Start) + 1    
END    
RETURN LTRIM(RTRIM(@HTMLText))    
END 
Comment

PREVIOUS NEXT
Code Example
Sql :: raiserror with nowait 
Sql :: select value from previous row in postgresql 
Sql :: mysql not empty 
Sql :: how to define a save method in ruby for sql databases 
Sql :: postgresql remove duplicate rows 2 columns 
Sql :: insert query mysql workbench 
Sql :: sqlite copy table to another table 
Sql :: how to get parent and child record in single query using sql 
Sql :: mysql dump for selected row 
Sql :: group by por mes sql mysql 
Sql :: sql order by with where 
Sql :: sql insert values into table 
Sql :: SQL add a totals of differemt rows of the same id 
Sql :: declare temp table in sql 
Sql :: mysql into outfile with headers 
Sql :: android sqlite query join 
Sql :: run psql postgres docker 
Sql :: how to convert external table to managed table in hive 
Sql :: mysql last friday of current month 
Sql :: tsql edit table column 
Sql :: sql date with month and year only 
Sql :: sql server set default value equal to auto increment 
Sql :: sql exemplos 
Sql :: wamp server mysql password 
Sql :: SQL INNER JOIN With Three Tables 
Sql :: t-sql never ending delete 
Sql :: sql not equal to operator 
Sql :: oracle uptime 
Sql :: postgres add prefix to primary key 
Sql :: oracle disk group space 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =