2

I'm testing Microsoft SQL Server, I want to check that how much time it takes when I perform a query.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

3 Answers3

2

In the query window place SQL like below:

SET STATISTICS TIME ON;  

--Your Query Goes Here 
SELECT * FROM Table

SET STATISTICS TIME OFF;  
Khorshed Alam
  • 314
  • 2
  • 11
1
Declare @startDate datetime
Declare @endDate datetime
begin

set @startDate=GETDATE()
select * from Table1
set @endDate=GETDATE()
 select DATEDIFF(ms,@startDate,@endDate) as 'Execution Time '


     /*
 ms is for millisecond you can also use following argument
 minute mi, n
second  ss, s
millisecond ms
microsecond mcs
nanosecond  ns
 */
 end
Hitesh Thakor
  • 471
  • 2
  • 12
0
DECLARE @EndT datetime
DECLARE @StartT datetime 
SELECT @StartT=GETDATE() 

-- Write Your Query


SELECT @EndT=GETDATE()

--This will return execution time of your query
SELECT DATEDIFF(ms,@StartT,EndT) AS [Execution Time in millisecs]

for more information About DATEDIFF See https://learn.microsoft.com/en-us/sql/t-sql/functions/datediff-transact-sql

Imran Ali Khan
  • 8,469
  • 16
  • 52
  • 77