Measure the time it takes to execute a t-sql query

Viewed 254444

I have two t-sql queries using SqlServer 2005. How can I measure how long it takes for each one to run?

Using my stopwatch doesn't cut it.

7 Answers

Another way is using a SQL Server built-in feature named Client Statistics which is accessible through Menu > Query > Include Client Statistics.

You can run each query in separated query window and compare the results which is given in Client Statistics tab just beside the Messages tab.

For example in image below it shows that the average time elapsed to get the server reply for one of my queries is 39 milliseconds.

Result

You can read all 3 ways for acquiring execution time in here. You may even need to display Estimated Execution Plan ctrlL for further investigation about your query.

Click on Statistics icon to display and then run the query to get the timings and to know how efficient your query is

`declare @time1 as datetime =getdate()

SELECT * FROM [dbo].[Sheet1] where name like '%d%'

declare @time2 as datetime =getdate() select @time2-@time1`

This simply works champ

Related