473,385 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

String replacement

Help, I have a vendor file with the vendors name. I need to add a
field that has alternate captions
eg. :
In my vendor file I have records for AT&T with three different
names/spellings for AT&T.

AT&T
Lucent Technologies
A T & T

I want to add a new field that would have AT&T for the above records.

I know I could hardcode a query
Update F_VENDOR
Set VENDOR_CAPTION_ALT = 'AT&T'
where VENDOR_CAPTION like '%Lucent%' or
VENDOR_CAPTION like '%A T & T%'

however, how can I use another table that has the my search keywords
for the "like" and the replacement captions so I dont need literal
queries to update all the diffent vendors?

I have identified 96 instances of where I want to have an alternative
name that I can use for a type of grouping. This gets really wild
with the military such as Army and Navy.
TIA
Rob
Jul 20 '05 #1
4 2388
For a longer-term solution, you need a vendor table and your
application should force the user to pick from a list populated by
that table, so that you don't get this problem in the future.

On 20 Jan 2004 06:23:44 -0800, rc******@cablespeed.com (R Camarda)
wrote:
Help, I have a vendor file with the vendors name. I need to add a
field that has alternate captions
eg. :
In my vendor file I have records for AT&T with three different
names/spellings for AT&T.

AT&T
Lucent Technologies
A T & T

I want to add a new field that would have AT&T for the above records.

I know I could hardcode a query
Update F_VENDOR
Set VENDOR_CAPTION_ALT = 'AT&T'
where VENDOR_CAPTION like '%Lucent%' or
VENDOR_CAPTION like '%A T & T%'

however, how can I use another table that has the my search keywords
for the "like" and the replacement captions so I dont need literal
queries to update all the diffent vendors?

I have identified 96 instances of where I want to have an alternative
name that I can use for a type of grouping. This gets really wild
with the military such as Army and Navy.
TIA
Rob


Jul 20 '05 #2
R Camarda (rc******@cablespeed.com) writes:
I want to add a new field that would have AT&T for the above records.

I know I could hardcode a query
Update F_VENDOR
Set VENDOR_CAPTION_ALT = 'AT&T'
where VENDOR_CAPTION like '%Lucent%' or
VENDOR_CAPTION like '%A T & T%'

however, how can I use another table that has the my search keywords
for the "like" and the replacement captions so I dont need literal
queries to update all the diffent vendors?


IF I understand this correctly:

UPDATE F_VENDOR
SET VENDOR_CAPTION_ALT = r.good_caption
FROM F_VENDOR f
JOIN replacements r ON f.VENDORC_CAPTION LIKE '%' + r.bad_caption + '%'
--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #3
Ellen K. <72************************@compuserve.com> wrote in message news:<74********************************@4ax.com>. ..
For a longer-term solution, you need a vendor table and your
application should force the user to pick from a list populated by
that table, so that you don't get this problem in the future.


Absolutely, However I don't have control over the source application
and I am trying to do data cleansing for a data warehouse.

Also, the solution will help expand my knowledge of SQL techniques
that, in turn, I may help someone else someday.
Jul 20 '05 #4
Erland Sommarskog <so****@algonet.se> wrote in message news:<Xn**********************@127.0.0.1>...

Erland, that did the trick. Thank you very much!

Rob
IF I understand this correctly:

UPDATE F_VENDOR
SET VENDOR_CAPTION_ALT = r.good_caption
FROM F_VENDOR f
JOIN replacements r ON f.VENDORC_CAPTION LIKE '%' + r.bad_caption + '%'

Jul 20 '05 #5

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

Similar topics

3
by: Juha Suni | last post by:
Hi! I have managed to live without using too much regular expressions so far, and now that I need one, I need some help too. I have a string containing a (possibly large) block of html. I need...
5
by: Roose | last post by:
How can I do a "".replace operation which tells me if anything was actually replaced? Right now I am doing something like: if searchTerm in text: text = text.replace( searchTerm, 'other' ) ...
11
by: Christopher Benson-Manica | last post by:
Let's say I have a std::string, and I want to replace all the ',' characters with " or ", i.e. "A,B,C" -> "A or B or C". Is the following the best way to do it? int idx; while(...
13
by: dimitris67 | last post by:
How can I replace an occurence of p(a string) in an other string(s) with np(new string).. char* replace _pattern(char *s,char *p,char *np) PLEASE HELP ME!!!!!
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
35
by: jacob navia | last post by:
Hi guys! I like C because is fun. So, I wrote this function for the lcc-win32 standard library: strrepl. I thought that with so many "C heads" around, maybe we could improve it in a...
29
by: zoltan | last post by:
Hi, The scenario is like this : struct ns_rr { const u_char* rdata; }; The rdata field contains some fields such as :
21
by: gary | last post by:
How would one make the ECMA-262 String.replace method work with a string literal? For example, if my string was "HELLO" how would I make it work in this instance. Please note my square...
5
by: int main(void) | last post by:
Hi all, Following is my attempt to write a string search and replace function. #include <stdio.h> #include <stdlib.h> #include <string.h>...
4
by: Phil Sandler | last post by:
Hello, What is the fastest/most efficient way of doing string replacement in csharp/.net? An example would be: "Hello, my name is {FirstName}, and I live in the town of {City} with my wife...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
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...

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.