This simply keys off of the 1st not integer character following the start of the numeric sequence...
It could also be easily converted into a very efficient iTVF...
DECLARE @url VARCHAR(8000) = 'http://www.mydomain.info/Customer.aspx?h_hmid=2907831&dcc=EUR&mobiredirect=no&cpn=3790';
SELECT
LEFT(
SUBSTRING(
@url,
CHARINDEX('hmid=', @url) + 5, 8000),
PATINDEX('%[^0-9]%',
SUBSTRING(
@url,
CHARINDEX('hmid=', @url) + 5, 8000)
) -1
)