• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 39
  • Last Modified:

retrieve a substring from a separated string in a table

Hi

I'm looking for a simple way to retrieve the second sub string out off a string separated based on point seprators.

The field value (nvarchar(20)) has these kind or formats:

01.0.A.01          
19.05.-.108
95.3.Z.326

and I'd like to retrieve the second segment from the string. So based on the three examples the outcome should be:

0
05
3

Hope you can help.
0
Steynsk
Asked:
Steynsk
1 Solution
 
Vaibhav GoelMSBI , SQL ConsultantCommented:
Hello Steynsk

SELECT
      SUBSTRING(vals,CHARINDEX('.',vals,0)+1, CHARINDEX('.',vals,CHARINDEX('.',vals,0)+1)-CHARINDEX('.',vals,0)-1) op
FROM yourtableName

op
---
0
05
3
1
 
SteynskAuthor Commented:
Thanks Vaibhav  an excellent answer to my question.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now