Solved

SQL Pull data from a variable out of another variable

Posted on 2011-03-08
3
238 Views
Last Modified: 2012-05-11
OK.. I have a variable called @Location.. The data in it is this: 500 Main St Greensboro NC 27401..

I have the following variables called @City, @State and @Zip.. Each of them has already been populated with the information above.. For example @City is populated with Greensboro and @State is populated with NC etc... I was able to populate the three variables from @Location.. However now I need to strip out the City, State and Zip from @Location so all I have left in @Location is 500 Main St...What is the best way?
0
Comment
Question by:cheryl9063
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 35070223
something like:
set @location = replace(@location, @city, '')
set @location = replace(@location, @Zip, '')
set @location = replace(@location, @State, '')

Open in new window

0
 
LVL 32

Expert Comment

by:awking00
ID: 35070275
You may want to rtrim angelIII's solution to remove unnecessary spaces at the end.
set @location = rtrim(@location)
0
 
LVL 1

Author Closing Comment

by:cheryl9063
ID: 35070330
Thanks!
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

685 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