• Oh yes. And I also noticed that your conversion of my DATETIME2 code causes the same 1ms of inaccuracy.

    So presumably, if we're willing to live with 1ms of inaccuracy, we can change the DATETIME2 compatible version to this:

    RAISERROR('========== DATETIME2 Compatible ==========',0,1) WITH NOWAIT;

    DECLARE @TimeToAdd CHAR(12),

    @Bitbucket DATETIME;

    SELECT @TimeToAdd = '41:41:41.041';

    SET STATISTICS TIME ON;

    SELECT @Bitbucket = DATEADD(hour, CAST(LEFT(@TimeToAdd, 2) AS INT)

    ,DATEADD(ms

    ,DATEDIFF(ms, 0, '00:'+RIGHT(@TimeToAdd, 9))

    ,SomeDateTime))

    FROM dbo.JBMTest;

    SET STATISTICS TIME OFF;

    Which results in a bit closer horse race:

    ========== Simple date addition ==========

    SQL Server Execution Times:

    CPU time = 266 ms, elapsed time = 271 ms.

    ========== DATETIME2 Compatible ==========

    SQL Server Execution Times:

    CPU time = 280 ms, elapsed time = 291 ms.

    Mine still loses mind you but not by as much and I never mind losing to a champion in the performance arena such as yourself!


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St