If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Extract a string from a word

Started by yogeswari, 07 Nov 2013 04:01:54 AM

Previous topic - Next topic

yogeswari

Hi All,

Can anyone provide solutions for the issue:

Column Values=ASP-000123 or it can be
                        AMP-000123 or it can be
                        BP Initial-000123 or it can be
                        BP Restated-000123
Required=>000123

I need to extract ASP if the value is (ASP-000123) But answer should come 000123
I need to extract AMP if the value is (AMP-000123) But answer should come 000123
I need to extract BP Initial if the value is (BP Initial-000123) But answer should come 000123
I need to extract BP Restated if the value is (BP Restated-000123) But answer should come 000123

How to do this?
I tried by using substring and Trim function but Trim function removes single character only.  I need to remove set of characters or string of values.

Could please anyone provide solution as will consider your help as Great

Thanks,
Yogeswari.


BigChris

From your sample data it looks like the number you're looking for is always preceded by "-". You should be able to FIND that character and use that as the starting point for your substring. It depends on what platform you're using, but if you're using SQL server you probably want to use something like CHARINDEX.

C

Grim

If the numbers you want are always 6 characters and depending on what DB you are using you should be able to just do a...
right([CommonValue], 6)

You can also try...
substring([CommonValue], -6)
"Honorary Master of IBM Links"- MFGF
Certified IBM C8 & C10 Admin, Gamer, Geek and all around nice guy.
<-Applaud if my rant helped! 8)

yogeswari

Hi All,

Thank you so much for your responses :).  I tried by using Substring and Trim function.
Its works fine.

Thank you all your responses.  Will get back to you if anything i struggle.

Thanks,
Yogeswari.