timing sql queries

Solutions on MaxInterview for timing sql queries by the best coders in the world

showing results for - "timing sql queries"
Constanza
10 Oct 2018
1DECLARE @t1 DATETIME;
2DECLARE @t2 DATETIME;
3
4SET @t1 = GETDATE();
5SELECT /* query one */ 1 ;
6SET @t2 = GETDATE();
7SELECT DATEDIFF(millisecond,@t1,@t2) AS elapsed_ms;
8
9SET @t1 = GETDATE();
10SELECT /* query two */ 2 ;
11SET @t2 = GETDATE();
12SELECT DATEDIFF(millisecond,@t1,@t2) AS elapsed_ms;
Federica
14 Jun 2017
1SELECT GETDATE();
2SELECT /* query one */ 1 ;
3SELECT GETDATE();
4SELECT /* query two */ 2 ; 
5SELECT GETDATE(); 
6