SQL Server Management Studio, how to get execution time down to milliseconds

后端 未结 8 1543
花落未央
花落未央 2020-12-07 07:08

When I submit a batch (e.g., perform a query) in SSMS, I see the time it took to execute in the status bar. Is it possible to configure SSMS to show the query time with mill

8条回答
  •  不思量自难忘°
    2020-12-07 07:45

    To get the execution time as a variable in your proc:

    DECLARE @EndTime datetime
    DECLARE @StartTime datetime 
    SELECT @StartTime=GETDATE() 
    
    -- Write Your Query
    
    
    SELECT @EndTime=GETDATE()
    
    --This will return execution time of your query
    SELECT DATEDIFF(ms,@StartTime,@EndTime) AS [Duration in millisecs] 
    

    AND see this

    Measuring Query Performance : "Execution Plan Query Cost" vs "Time Taken"

提交回复
热议问题