Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

How I can print the execution time of each query on messages Pane? For example the Select * from tbl1 runs for 10 mins then Select * from tbl2 runs for 15mins and so on..

Select * from tbl1
Go
Select * from tbl2
Go
Select * from tbl3
Go
share|improve this question
    
SET STATISTICS TIME ON; –  Aaron Bertrand Jul 9 at 3:15
    
@Mark Surely, but it was just a comment, not an answer, sorry I didn't have time last night to be more thorough. –  Aaron Bertrand Jul 9 at 12:15
    
@AaronBertand Sorry! Wasn't criticising! –  Mark Sinkinson Jul 9 at 12:17
    
@Mark it's ok, you're right. For quick stuff it's probably good enough. –  Aaron Bertrand Jul 9 at 14:50

1 Answer 1

DATEDIFF will be useful

DECLARE @StartTime1 datetime 

SET @StartTime1 = GETDATE()

select query 1

SELECT ExecutionTimeInMS = DATEDIFF(millisecond, @StartTime1, getdate())

GO

similarly do for other queries. @starttime2, 3

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.