Solved

SQL Pull data from a variable out of another variable

Posted on 2011-03-08
3
235 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 142

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

'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 …
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 video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

912 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now