473,804 Members | 3,515 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQL REPLACE STATEMENT - CONSOLIDATION

Can these lines of sql statements be consolidated into one sql statement
(possibly using reg exps??)

BEGIN CODE
+++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++ ++++++++++++
Update applications Set news_article = replace(news_ar ticle, '<FONT
face="Times New Roman" color=#000000 size=3>', '');
Update applications Set news_article = replace(news_ar ticle, '<P
class=MsoNormal style="MARGIN: 0cm 0cm 0pt">', '');
Update applications Set news_article = replace(news_ar ticle,
'<?xml:namespac e prefix = o ns = "urn:schema s-microsoft-com:office:offi ce"
/>', '');
Update applications Set news_article = replace(news_ar ticle, '<o:p>', '');
Update applications Set news_article = replace(news_ar ticle, '</o:p>', '');
Update applications Set news_article = replace(news_ar ticle, '</P>', '');
Update applications Set news_intro = replace(news_in tro, '<FONT face="Times
New Roman" color=#000000 size=3>', '');
Update applications Set news_intro = replace(news_in tro, '<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt">', '');
Update applications Set news_intro = replace(news_in tro, '<?xml:namespac e
prefix = o ns = "urn:schema s-microsoft-com:office:offi ce" />', '');
Update applications Set news_intro = replace(news_in tro, '<o:p>', '');
Update applications Set news_intro = replace(news_in tro, '</o:p>', '');
Update applications Set news_intro = replace(news_in tro, '</P>', '');
Update applications Set news_article = replace(news_ar ticle, '<SPAN lang=FR
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial; mso-ansi-language:
FR">', '');
Update applications Set news_article = replace(news_ar ticle, '<SPAN lang=FR
style="COLOR: black; mso-ansi-language: FR">', '');
Update applications Set news_article = replace(news_ar ticle, '</SPAN>', '');
Update applications Set news_article = replace(news_ar ticle, '<FONT
color=#000000>' , '');
Update applications Set news_article = replace(news_ar ticle, '</FONT>', '');
Update applications Set news_article = replace(news_ar ticle, '<SPAN lang=FR
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial; mso-ansi-language:
FR">', '');
Update applications Set news_article = replace(news_ar ticle, '<SPAN lang=FR
style="COLOR: black; mso-ansi-language: FR">', '');
Update applications Set news_article = replace(news_ar ticle, '</SPAN>', '');
Update applications Set news_article = replace(news_ar ticle, '<FONT
color=#000000>' , '');
Update applications Set news_article = replace(news_ar ticle, '</FONT>', '');
Update applications Set news_intro = replace(news_in tro, '<SPAN lang=FR
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial; mso-ansi-language:
FR">', '');
Update applications Set news_intro = replace(news_in tro, '<SPAN lang=FR
style="COLOR: black; mso-ansi-language: FR">', '');
Update applications Set news_intro = replace(news_in tro, '</SPAN>', '');
Update applications Set news_intro = replace(news_in tro, '<FONT
color=#000000>' , '');
Update applications Set news_intro = replace(news_in tro, '</FONT>', '');

+++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++
END CODE

Many Thanks
Jul 17 '05 #1
4 3028
Craig Keightley wrote:
Can these lines of sql statements be consolidated into one sql statement
(possibly using reg exps??)

BEGIN CODE
+++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++ ++++++++++++
Update applications Set news_article = replace(news_ar ticle, '<FONT
face="Times New Roman" color=#000000 size=3>', '');
Update applications Set news_article = replace(news_ar ticle, '<P
.... etc. etc.


What are you trying to do? These statments are to clean HTML tags from
records in your database. If it's a one-off to clean up your database
then just run it as is. If it's a regular job then you ought to look
into cleaning the data before it gets there.

strip_tags is very useful for cleanup purposes. You can specify which
tags to explicitly allow (<b>,<i> etc) and write the clean version to
your database.

Jul 17 '05 #2
>Can these lines of sql statements be consolidated into one sql statement
(possibly using reg exps??)
You might be able to put this in one big mess:

Update applications Set news_article = replace(replace (replace(replac e(replace(repla ce(replace(repl ace(replace(new s_article, '<SPAM>', ''), '</SPAM>', '') ...

but it looks very messy to maintain. You can also do news_article
and news_intro in the same statement.

Gordon L. Burditt
BEGIN CODE
++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++
Update applications Set news_article = replace(news_ar ticle, '<FONT
face="Times New Roman" color=#000000 size=3>', '');
Update applications Set news_article = replace(news_ar ticle, '<P
class=MsoNorma l style="MARGIN: 0cm 0cm 0pt">', '');
Update applications Set news_article = replace(news_ar ticle,
'<?xml:namespa ce prefix = o ns = "urn:schema s-microsoft-com:office:offi ce"
/>', '');
Update applications Set news_article = replace(news_ar ticle, '<o:p>', '');

....
Jul 17 '05 #3
Hopefully its a one off
I have a page where the user can isert a record but it uses a div id
instead of a textarea When the form is submitted, it passes the data in the
div id to a hidden field and the hidden field is entered into the db.
The reason for this is the user can format the text to make it bold text and
or italic. But thats all they can do. If a user copies and pastes text
froma word document, it also copies the format of the text from that
document. Therefore all the additional xmal items are included.
I would use strip_tags but the allowable tags are used in the document also
(<P> tag etc)

Thanks for the help though

Craig
"Kevin Thorpe" <ke***@pricetra k.com> wrote in message
news:41******** *************** @news.easynet.c o.uk...
Craig Keightley wrote:
Can these lines of sql statements be consolidated into one sql statement
(possibly using reg exps??)

BEGIN CODE
+++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++ ++++++++++++
Update applications Set news_article = replace(news_ar ticle, '<FONT
face="Times New Roman" color=#000000 size=3>', '');
Update applications Set news_article = replace(news_ar ticle, '<P ....
etc. etc.


What are you trying to do? These statments are to clean HTML tags from
records in your database. If it's a one-off to clean up your database then
just run it as is. If it's a regular job then you ought to look into
cleaning the data before it gets there.

strip_tags is very useful for cleanup purposes. You can specify which tags
to explicitly allow (<b>,<i> etc) and write the clean version to your
database.

Jul 17 '05 #4
*** Craig Keightley escribió/wrote (Wed, 6 Oct 2004 12:15:47 +0100):
Can these lines of sql statements be consolidated into one sql statement
(possibly using reg exps??)


You're going to kill your database server, which is the typical bottleneck
in a dynamic web site. My suggestion:

1) Write a PHP function to cleanup text
2) Get data from DB
3) Clean data with your PHP function
4) Put data back into DB
--
-+ Álvaro G. Vicario - Burgos, Spain
+- http://www.demogracia.com (la web de humor barnizada para la intemperie)
++ Las dudas informáticas recibidas por correo irán directas a la papelera
-+ I'm not a free help desk, please don't e-mail me your questions
--
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
4517
by: middletree | last post by:
What's wrong with this code? strLongDesc = Replace(Replace(Replace(Replace(Trim(Request.Form("LongDesc")),"'","''"),vbC rLf,"<br>"),"<",&lt;),"<",&gt;) Background: This field is a textarea, and I needed to account for apostrophes, which I had already done, and replaced line breaks with html line breaks on my page which displays this stuff. That works fine. But then a user entered this
1
5111
by: eddie wang | last post by:
I try to replace the following STATEMENT ONE with STATEMENT TWO. But it doesn't work. How to make it work??? Thanks. STATEMENT ONE: <td colspan="10" align="center"><a href="ExcelExport.asp?noIncludes=yes&sqlStr=<%=replace(Server.URLEncode( strSQl),"'","`")%>"><img src='images/excel.gif' border='0' alt='Export to Excel'></a></td> STATEMENT TWO:
9
7906
by: Richard Gutery | last post by:
I have this piece of code in an ASP page: replace (strRootDir, "\", "/", -1) When I run the script I get: Microsoft VBScript compilation (0x800A0414) Cannot use parentheses when calling a Sub II remove the parenthese then I get: Microsoft VBScript compilation (0x800A0401) Expected end of statement
2
8625
by: Little PussyCat | last post by:
Hello, I need to be able to replace only the first occurance of a space character in a column. Reason being is the data in the column I am trying to replace seems to have umpteen space characters after each entry, so a simple replace function will replace all the spaces after it with what I want! I have thought of RTRIM to get rid of the spaces after and then replace, I have also thought of CHARINDEX to find the first occurance of a...
3
5456
by: Andy Sutorius | last post by:
Hi, I read the thread (2/16/05) regarding a replace function in C# however it didn't answer my question. I have a string which is building an insert sql statement and I would like to replace apostrophes of the form fields. I was trying to do something like this: string sqlInsertEmails = "insert into tblContent (content, subject) values ('" + Replace(txtBody.Text,"'","''") + "', '" + Replace(txtSubject.Text,"'","''") + "')";
8
16119
by: Guy | last post by:
Hi, I'm trying to run this code : strFileContentsHTML.Replace(vbLf, "<br>") strFileContentsHTML.Replace(vbCrLf, "<br>") strFileContentsHTML.Replace(vbCr, "<br>") It doesn't replace newline characters with <br>.
2
8938
by: Curtiosity | last post by:
I have done a create or replace view called creditcard1. If I do a "select * from creditcard1" it retrieves the data just fine. If I try to do a statement where I am listing the column names it doesn't recognize them. create or replace view creditcard1 as select pidm ,tbraccd_term_code as "Term" ,tbraccd_detail_code as "Detail_Code" ,tbbdetc_desc as "Detc_Desc" ,tbraccd_tran_number as "Tran_Number" ,DECODE(tbbdetc_type_ind,...
10
1724
by: bobtehdog | last post by:
Column Consolidation. My problem is this. I have to sort each of the def1-def23 columns from the old table into the def1-def6 columns from the new table preserving the other data in the records. So basically, i have 23 categories that I have to sort into 6 broader or more general categories. I have tried updating/appending the data in the query design view, but I end up with syntactic errors every time due to my lack of knowledge. Below...
2
1527
by: Jeremy | last post by:
I am trying to replace a string "P" with "\P" as long as the string "P" does not already have a "\" in front. for my search string I've used @"(P)" so my regex replace statement is: System.Text.RegularExpressions.Regex pR = new System.Text.RegularExpressions.Regex(@"(P)"); string strResult = pR.Replace(@"This is a XP test X\P", @"\P"); The poblem is that the statement replaces XP with \P where I want it to be
0
9705
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9576
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10568
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10074
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9138
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5516
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2988
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.