Wednesday, 28 June 2017

SQL Server - HTML to TEXT

CREATE FUNCTION [dbo].[HTMLtoText] (@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
GO

Command to Test:
SELECT dbo.HTMLtoText('<h1>Everything is possible, nothing is <span style="color: red"><b>impossible.</b> </span>:)</h1>')


Tuesday, 27 June 2017

C# ASP.NET Rich Text Box/Editor

The most-used free ASP.NET WYSIWYG HTML editor featured in open source and commercial projects more...


SQL: Generate a range of numbers

SELECT ones.n + 10*tens.n + 100*hundreds.n + 1000*thousands.n FROM       (VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) ones(n),      (VALU...