Solved

Exact string match and replace in SQL??

Posted on 2008-10-01
3
2,033 Views
Last Modified: 2008-10-01
Hi,

This column called Destinations has country names like Cananda,France or Iran/Syria.
I am trying to replace those with the trigraphs.
How do I match exact string??

I changed Iran to IRQ then I had a few IR. so when I replace IR with IRQ.
Previous IRQ became, IRQQ.

Is it possible to match exactly string not partial??

I used update table set location=replace(location, 'sss','dffdf')

Thannks

0
Comment
Question by:dkim18
3 Comments
 
LVL 22

Accepted Solution

by:
dportas earned 350 total points
ID: 22619061
Use the WHERE clause for an exact match on the string:

UPDATE tbl SET location = 'sss'
WHERE location = 'dffdf';
0
 
LVL 39

Assisted Solution

by:BrandonGalderisi
BrandonGalderisi earned 150 total points
ID: 22619295
This won't be the most efficient because it will update Location = location for all records that you don't specify.... but it give you the idea on how to build it out.
update YourTable
set Location = case location when 'IR' then 'IRQ'
                                when 'IRAN/SYRIA' then 'IRN'
                                when 'Canada' then 'CAN'
                                else location
end

Open in new window

0
 

Author Comment

by:dkim18
ID: 22619591
Thanks.
It came to me after I saw this....hhh.!!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question