SQLTeam.com | Weblogs | Forums

How to extract value between dot and hyphen second part


#1

declare @Sample table (Proj_name varchar(100))
insert @Sample
select '123.234-martiinternational.pdf' union all
select '22356.2894-martiinternational.pdf' union all
select '6758.1287-papa.pdf'

I want to get the second part from right between dot and hypen
which is 234, 2894 and 1287

Thank you very much for the helpful info.


#2
SELECT * , 
	STUFF(LEFT(Proj_name,CHARINDEX('-',Proj_name+'-')-1),1,CHARINDEX('.',Proj_name+'.'),'') 
FROM @sample;

#3

@gbritton case :stuck_out_tongue: