Hey Eddie!
I like this conversation very much!
Try this with only 100.000 recs!
if object_id ('tempdb.dbo.#TimeTrial') is not null drop table #TimeTrial
create table #TimeTrial (id integer identity(1,1), Event varchar (20), datestart datetime default getdate (), dateend datetime null)
declare @counter integer
set @counter=1
while @counter<13
begin
insert #TimeTrial (Event) values ('Richard')
update HexTest set ASCIIValue = dbo.f_hextostr (HexValue)
update #TimeTrial set dateend=getdate() where id=@counter
set @counter=@counter+1
insert #TimeTrial (Event) values ('Eddie')
update HexTest set ASCIIValue = dbo.fn_HexToAlpha (HexValue)
update #TimeTrial set dateend=getdate() where id=@counter
set @counter=@counter+1
end
select *, dateend-datestart as diff from #TimeTrial order by id
The result:
1 Richard 00:00:17.333
2 Eddie 00:00:08.283
3 Richard 00:00:06.610
4 Eddie 00:00:08.010
5 Richard 00:00:06.420
6 Eddie 00:00:08.000
7 Richard 00:00:06.520
8 Eddie 00:01:02.360
9 Richard 00:00:06.460
10 Eddie 00:00:07.780
11 Richard 00:00:06.510
12 Eddie 00:00:07.803
Conclusions: The first runs (1-2) must be eliminated, our data not in cash yet. The runs 7-8 must be eliminated, Your result totally differs from others ( really sometimes I don't know, what the hell is running on background), the rest results are comparable.
By the way: our functions are able to run faster, if:
You eliminate the UPPER function (suppose the HEX string is correct);
I eliminate the IF part (suppose the HEX string is correct)
Best regards: Richard