• For anyone that would like to do their own testing, here's the test table I've been using for all of this...

    WITH cteRandomDT AS

    (

    SELECT TOP 1000000

    DateTimeDT = RAND(CHECKSUM(NEWID())) * DATEDIFF(dd,'2000','2020') + CAST('2000' AS DATETIME)

    FROM sys.all_columns ac1

    CROSS JOIN sys.all_columns ac2

    )

    SELECT DateTimeDT

    ,DateTime2DT = CAST(DateTimeDT AS DATETIME2(3))

    INTO #JBMTest

    FROM cteRandomDT

    ;

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)