Sam OZ
asked on
Sql Server query to get substring
Hi I have a table TB-Docs in Sql Server 2016 with a filed Name ( and other fields) . There are some names ending like Doc1VOL01 , Doc1VOL11 , Doc1Vol123
Eg.
Doc1Vol01
Doc1Vol11
Doc3Vol123
I need result with Volume rows and the substring of the Document name ( All I need to know is how to get the substring like Doc1 from a string of Doc1Vol01)
Name Doc
----- ----
Doc1Vol01 Doc1
Doc1Vol11 Doc1
Doc3Vol123 Doc3
Edit : Name can be of any length , for example, there can be a Doooooc1Vol01
Eg.
Doc1Vol01
Doc1Vol11
Doc3Vol123
I need result with Volume rows and the substring of the Document name ( All I need to know is how to get the substring like Doc1 from a string of Doc1Vol01)
Name Doc
----- ----
Doc1Vol01 Doc1
Doc1Vol11 Doc1
Doc3Vol123 Doc3
Edit : Name can be of any length , for example, there can be a Doooooc1Vol01
ASKER
Sorry, The document can be of any length , For example there can be DoooooocVol123
So, what is the criteria for the extract? Everything up until Vol?
So, in the example above, you would want Doooooc?
So, in the example above, you would want Doooooc?
ASKER
That is right- extract Everything up until Vol
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Of course you need to use [TB-Docs] in above query ;-)
Oops ...yes, of course!
Open in new window