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

后端 未结 8 1539
花落未央
花落未央 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

    I was after the same thing and stumbled across the following link which was brilliant:

    http://www.sqlserver.info/management-studio/show-query-execution-time/

    It shows three different ways of measuring the performance. All good for their own strengths. The one I opted for was as follows:


    DECLARE @Time1 DATETIME

    DECLARE @Time2 DATETIME

    SET @Time1 = GETDATE()

    -- Insert query here

    SET @Time2 = GETDATE()

    SELECT DATEDIFF(MILLISECOND,@Time1,@Time2) AS Elapsed_MS


    This will show the results from your query followed by the amount of time it took to complete.

    Hope this helps.

提交回复
热议问题