TSQL - Left/Right string

Hi Experts

I have this query:
Select Instructions,
From TableName
Where Instructions Like 'DMRF%'

Open in new window


I get this data from the query:
Instructions
DMRF=445.00
DMRF=500.00
DMRF=555.00
DMRF=350.00
DMRF=350.00
DMRF=350.00
DMRF=350.00

Open in new window


I need to get this part only:
Instructions
445.00
500.00
555.00
350.00
350.00
350.00
350.00

Open in new window


So something like:
Right([Instructions], '=') As Amount

I don't think that is the correct syntax?

Please help and thanks...
Amour22015Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Select 
   -- If the DMRF= is always there, and always five characters
   RIGHT(Instructions, LEN(Instructions) - 5) , 
   -- Delete DMRF= if it's there, and if it's not then pass whatever is there
   CASE WHEN LEFT(Instructions, 5) = 'DMRF=' THEN RIGHT(Instructions, LEN(Instructions) - 5) ELSE Instructions END
From TableName
Where Instructions Like 'DMRF%'

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Amour22015Author Commented:
I do have some that are:
DMRF=25000.00 which your Right statement gives me 25000.00

So that still looks good.

I don't need the .00 at the end of each amount.

Thanks...
0
Scott PletcherSenior DBACommented:
My preference would be to avoid requiring a fixed length, so I would do this:

SELECT REPLACE(SUBSTRING(Instructions, CHARINDEX('=', Instructions) + 1, 100), '.00', '')
FROM ...
0
Amour22015Author Commented:
Ok, great thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.