If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > How to some text withing a field

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-11-04, 15:25
rlassiter rlassiter is offline
Registered User
 
Join Date: Sep 2004
Posts: 5
How to some text withing a field

Are there any examples of an update query that can search a field for a set of characters and replace only those characters? EG "ABC1234" change all BC to DE.
Reply With Quote
  #2 (permalink)  
Old 09-11-04, 18:23
urquel urquel is offline
Registered User
 
Join Date: Aug 2004
Posts: 330
Depending upon your dbms, try looking for a REPLACE() function.

It might look something like this:

UPDATE TABLE1
SET COL1 = REPLACE(COL1,'BC','DE')
WHERE ...

You will have to read your manuals to find the exact syntax for the function.(If it exitsts.)
Reply With Quote
  #3 (permalink)  
Old 09-16-04, 16:39
Matt_T_hat Matt_T_hat is offline
Registered User
 
Join Date: Sep 2003
Location: UK
Posts: 122
You might find it faster to return the record set "...where [field] like * &[search term] & *" and then itterate thru' the recordset doing an update little by little (unless the fields are more or less the same.

It will be slowish to VERY VERY slow to do it that way (depends on a bunch of stuff) so if Replace() works with your SQL version go for it. Otherwise welcome to slow-ville.
__________________
Matt the Hat says: "what!?"
A child of five could understand this! Fetch me a child of five!
SCARY HARD CHALLENGE: http://www.dbforums.com/database-concepts-design/988682-better-relational-design.html
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On