Solved

SQL Pull data from a variable out of another variable

Posted on 2011-03-08
3
234 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
Comment Utility
something like:
set @location = replace(@location, @city, '')
set @location = replace(@location, @Zip, '')
set @location = replace(@location, @State, '')

Open in new window

0
 
LVL 31

Expert Comment

by:awking00
Comment Utility
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
Comment Utility
Thanks!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 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

11 Experts available now in Live!

Get 1:1 Help Now