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
What you want to do is this:
set statistics time on
-- your query
set statistics time off
That will have the output looking something like this in your Messages window:
SQL Server Execution Times: CPU time = 6 ms, elapsed time = 6 ms.
You can try this code:
USE AdventureWorks2012;
GO
SET STATISTICS TIME ON;
GO
SELECT ProductID, StartDate, EndDate, StandardCost
FROM Production.ProductCostHistory
WHERE StandardCost < 500.00;
GO
SET STATISTICS TIME OFF;
GO
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"
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.
Include Client Statistics by pressing Ctrl+Alt+S. Then you will have all execution information in the statistics tab below.
Turn on Client Statistics by doing one of the following:
Then you get a new tab which records the timings, IO data and rowcounts etc for (up to) the last 10 exections (plus averages!):