Here's a handy little function that will parse normal HTTP USER_AGENT strings and return either Mozilla/X.XX or MSIE X.XX (it also seems to get Opera and Konqueror properly). It's handy if you stuff this info into a database; for instance,select dbo.f_ParseBrowser(last_browser),count(*) from users group by dbo.f_ParseBrowser(last_browser) order by count(*) desc
Here's the function:CREATE FUNCTION dbo.f_ParseBrowser (@vcBrowser varchar(200))RETURNS varchar(50) AS BEGIN DECLARE @vcMoz varchar(15),@vcData varchar(200)DECLARE @iPos intselect @iPos=charindex(' ',@vcBrowser)if @iPos=0 return '(unkown): ' + @vcBrowserselect @vcMoz=substring(@vcBrowser,1,@iPos-1)select @vcData=substring(@vcBrowser,@iPos+1,200)select @iPos=patindex('%compatible; %',@vcData)if @iPos=0 return @vcMozselect @vcData=substring(@vcData,@iPos+12,len(@vcData)-12)select @iPos=CharIndex(';',@vcData)if @iPos=0 return @vcDataselect @vcData=substring(@vcData,1,@iPos-1)return @vcDataEND
Cheers-b