Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 214
  • Last Modified:

Select that removes html from text

Hello,

I would like to select text from a field but remove the HTML code below is a example.

"<script language="Javascript">xtraImgs = 2;</script> This item has a great feel and nice fit."
0
ubsmail
Asked:
ubsmail
1 Solution
 
Jagadishwor DulalBraces MediaCommented:
You can not remover any thing in query just fetch the record and you can create a function to remove html code.
0
 
Anthony PerkinsCommented:
Is the data type really text?
Are you still using SQL Server 2000?

If the answer is yes to both of those question than you will have no choice but to use the deprecated UPDATETEXT() function.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ubsmailAuthor Commented:
Yes it is a SQL Server 2000
0
 
Anthony PerkinsCommented:
And is the data type text?
If it is text, is the maximum length greater 8000?  You can find out by doing something like this:
SELECT MAX(DATALENGTH(YourTextCol))
From YourTableNameGoesHere

If the answer is yes to both of these questions than you will have to resort to using the deprecated UPDATETEXT() function.
0
 
ubsmailAuthor Commented:
The datatype is text and the below query returned 1546

SELECT MAX(DATALENGTH(FULLINFO))
From stockinf

0
 
Anthony PerkinsCommented:
Then you can use something like this:
UPDATE  stockinf
SET     FULLINFO = REPLACE(CAST(FULLINFO AS varchar(8000)), '<script language="Javascript">xtraImgs = 2;</script> This item has a great feel and nice fit.', '')
WHERE   PATINDEX('%<script language="Javascript">xtraImgs = 2;</script> This item has a great feel and nice fit.%', FULLINFO) > 0

Open in new window

0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now