!Aaron Aardvark! (1/9/2012)
Just for interest's sake, here's the in-line function written to use SQL Server 2012:
CREATE FUNCTION dbo.agent_datetime_inline
(
@Date integer,
@Time integer
)
RETURNS TABLE WITH SCHEMABINDING
AS RETURN
SELECT
DATETIMEFROMPARTS
(
@Date / 10000,
@Date / 100 % 100,
@Date % 100,
@Time / 10000,
@Time / 100 % 100,
@Time % 100,
0
) AS date_time
Test results using Jeff's rig:
Michael's code: 1155ms
New function: 670ms
Now THAT would make a cool "spackle" article... you should go for it, Paul. Thanks for the "preview".
--Jeff Moden
Change is inevitable... Change for the better is not.