• DECLARE @EndTime DATETIME

    DECLARE @StartTime DATETIME

    SET @StartTime = GETDATE()

    --... code here to be measured for duration

    SET @EndTime = GETDATE()

    PRINT 'StartTime = ' + CONVERT(VARCHAR(30),@StartTime,121)

    PRINT ' EndTime = ' + CONVERT(VARCHAR(30),@EndTime,121)

    PRINT ' Duration = ' + CONVERT(VARCHAR(30),@EndTime,114) + '(hh:mi:ss:mmm)'

    If that doesn't do it, then try SET STATISTICS TIME ON

    --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)