Pages

Dec 15, 2014

Function to get rid of all HTML tags in the summary


I had to provide Ticket summary to one of my user and got revert by asking to have the summary without HTML tags  L

Wondering if we have any such option and started google.

My goodness..found below function and it was working as per my request.

Create this function in your user Database and execute in the below mentioned way.

Function:

USE [DB NAME]

GO

/****** Object:  UserDefinedFunction [dbo].[udf_StripHTML]    Script Date: 12/15/2014 11:34:50 AM ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

 

ALTER FUNCTION [dbo].[udf_StripHTML] (@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

 

Execution:

 

declare @htmltext varchar(max);

declare @ret varchar(max);

 

 

exec @ret= [dbo].[udf_StripHTML] @htmltext='<p> <strong><u>ATTENTION SERVICES TEAM - </u></strong><br /> Contract # is being supported by Terix who provide TAC, Field support and NBD

replacement for the server equipment.<br /> <br /> will be fielding calls and looping in Terix as needed<br /> Our engineers are

to be on the call at all times<br /> Please do not mention Terix as the customer doesnt need to know this information<br /> Please

open a ticket with the customer’s contact details, serial #, and address where the equipment is located<br /> <br /> 1. Do not refuse

service<br /> 2. Let the customer know we will call them back shortly with a member from their dedicated support team<br /> 3. Call

Terix and establish a ticket or log in thru portal with provided username and password<br /> 4. When ready, conference in the customer

<br /> 5. All calls need an  tech on them, DO NOT GET OFF THE CALL<br /> 6. Terix IT handles Support, Spares & Logistics<br />

<br /> We have an arrangement with a 3rd party (Terix ) to support this customers equipment. Here is the procedure for creating a

ticket. You can also click on the truck next to the serial number for contact info.<br /> <br /> To open a ticket at any time 24 hours

/day<br /> Please call 1, ask for a support engineer and email </a><br /> Or Log in a ticket thru the portal @ < SOP for detials Should

an engineer not be available immediately please describe the problem and provide the following information: account name, your name,

call back number and summary of the issue you are experiencing.<br /> An engineer will call you back within 15- 30 minutes to begin

resolving your issue..<br />  </p>'

 

print @ret

 

Output:

ATTENTION SERVICES TEAM -  Contract # is being supported by Terix who provide TAC, Field support and NBD

replacement for the server equipment.  will be fielding calls and looping in Terix as needed Our engineers are

to be on the call at all times Please do not mention Terix as the customer doesnt need to know this information Please

open a ticket with the customer’s contact details, serial #, and address where the equipment is located  1. Do not refuse

service 2. Let the customer know we will call them back shortly with a member from their dedicated support team 3. Call

Terix and establish a ticket or log in thru portal with provided username and password 4. When ready, conference in the customer

 5. All calls need an  tech on them, DO NOT GET OFF THE CALL 6. Terix IT handles Support, Spares & Logistics

 We have an arrangement with a 3rd party (Terix ) to support this customers equipment. Here is the procedure for creating a

ticket. You can also click on the truck next to the serial number for contact info.  To open a ticket at any time 24 hours

/day Please call 1, ask for a support engineer and email  Or Log in a ticket thru the portal @  An engineer will call you back within 15- 30 minutes to begin

resolving your issue..

 

References:


No comments: