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
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi