Get Value from Url

i want to get the num-Value between the 2 Delimiters (h_hmid - and the End of the numeric Value)
in this case: 2907831 (var len of Value !)
What is the fastest way, to get all Values from a big Table? Is there a Index on this Column suggest ?



You could use CHARINDEX to locate the key strings ("h_hmid=" and "&") , then use SUBSTRING to extract the numeric portion and then use CAST or CONVERT to put it into a number. An index, however, won't be of assistance with any of that. HTH

declare @s varchar(max) = '';

select substring(@s, charindex('h_hmid=', @s) + 7, charindex('&', @s, charindex('h_hmid=', @s)) - charindex('h_hmid=', @s) - 7)