Solved

Remove all characters to the left of a specified character

Posted on 2011-03-08
2
340 Views
Last Modified: 2012-05-11
I have a column of data that has text like "New Price, now only $5.99"  

I would like to remove all the characters to the left of the dollar sign.

It would leave only the $5.99
0
Comment
Question by:theideabulb
2 Comments
 
LVL 16

Expert Comment

by:sjklein42
ID: 35075992
Something like this should do it:

SUBSTRING ( mystring , CHARINDEX ( mystring, '$' ), 10 )

Open in new window

see:

CHARINDEX ( expression1 ,expression2 [ , start_location ] )

http://msdn.microsoft.com/en-us/library/ms186323.aspx

SUBSTRING ( expression ,start , length )

http://msdn.microsoft.com/en-us/library/ms187748(v=sql.90).aspx
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 35082889
sjklein: the question is for MySQL, not mssql server.

the logic is the same, though, using the INSTR or LOCATE functions
http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_instr
http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_locate

and the substr / mid function(s):
http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_mid
http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_substring

watch out though about the order of the arguments in INSTR vs LOCATE (vs CHARINDEX), it's not always the same !
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

816 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

9 Experts available now in Live!

Get 1:1 Help Now