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 int
select @iPos=charindex(' ',@vcBrowser)
if @iPos=0
return '(unkown): ' + @vcBrowser
select @vcMoz=substring(@vcBrowser,1,@iPos-1)
select @vcData=substring(@vcBrowser,@iPos+1,200)
select @iPos=patindex('%compatible; %',@vcData)
if @iPos=0
return @vcMoz
select @vcData=substring(@vcData,@iPos+12,len(@vcData)-12)
select @iPos=CharIndex(';',@vcData)
if @iPos=0
return @vcData
select @vcData=substring(@vcData,1,@iPos-1)
return @vcData
END
Cheers
-b