Rip data from string

Can anyone help me to rip data from a string?  I have not been able to get it correct as it is not always the same one example  "4 X "5.02 X "5.32    another may be 2.5" X .75"  X 3" .
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

Pawan KumarDatabase ExpertCommented:
What output you need from your input.
Vitor MontalvãoMSSQL Senior EngineerCommented:
Are those mathematics expressions?
stevendeveloperAuthor Commented:
Sorry not mathematics, just a measurement. I need the numbers only
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Pawan KumarDatabase ExpertCommented:
"4 X "5.02 X "5.32  -------> 45.025.32 ??
stevendeveloperAuthor Commented:
No just              4  
Pawan KumarDatabase ExpertCommented:
3 rows ?
stevendeveloperAuthor Commented:
One row would fine with each value
Pawan KumarDatabase ExpertCommented:
Do you have a table where these values are stored?
stevendeveloperAuthor Commented:
Yes columns od, id, length
Pawan KumarDatabase ExpertCommented:
Please try full tested solution for you

Create table and data generation-

	a VARCHAR(100)

('"4 X "5.02 X "5.32'),('2.5" X .75"  X 3"')

Open in new window


	 ,LTRIM(RTRIM(REPLACE(SUBSTRING(a,CHARINDEX('X',a,CHARINDEX('X',a,0)+1)+1,LEN(a)),'"',''))) length

Open in new window



(2 row(s) affected)
od        id           length
--------- ------------ ------------
4         5.02         5.32
2.5       .75          3

(2 row(s) affected)

Open in new window

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
stevendeveloperAuthor Commented:
Id gives me the below error,

Msg 537, Level 16, State 3, Line 2
Invalid length parameter passed to the LEFT or SUBSTRING function.

the OD and Length are correct!!  Excellent  We are running sql 2012 r2
Pawan KumarDatabase ExpertCommented:
How many rows are there in your table? can you send you data to me in an excel?
stevendeveloperAuthor Commented:
There are many but I only pulled the top 100 and got the error.
stevendeveloperAuthor Commented:
Blew out on  2" DIA. X 6"  the 60th row...
Pawan KumarDatabase ExpertCommented:
What should be the output for above.
stevendeveloperAuthor Commented:
I got it used a case to find DIA and use null
stevendeveloperAuthor Commented:
Thank you Pawan.  I was able to use this just fine!  excellent job
Pawan KumarDatabase ExpertCommented:
Welcome. Happy to help as always. :)
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

From novice to tech pro — start learning today.