Query Execution Time

  • Hi Friends,

    I am Execution Some big query In Mangement Studio it will showing around 7min time.

    But my clinet is asking what time its execution is starting and Ending time

    Know i want Query Execution TIME and Ending Time

    what is the best why to find out Time

    Best Regasrds

    ms

  • You can use SQL Profiler. Trace the event T-SQL Batch completed and take the start time, end time and duration columns. Duration is in microseconds.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Hi Friend Thanku for response

    i am using SQL profiler but where it is exactly iam not understanding could plz tel me the step wise plz

    T&R

    ms

  • I think that you want the events SQL:BatchCompleted and RPC:completed.

    and then make sure that StartTime and EndTime columns as selected.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

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

  • Once you have identified the slow running query, you could also utilize the Include Client Statistics button located next to the Include Actual Query Plan in the SSMS(SQL Server Management Studio). Execute the query couple of times and you will be able to get an average execution time for your query

    Hope this helps

    Vinoj

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply