HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Print the execution time on messages Pane?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
thetimepaneprintmessagesexecution

Problem

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

Solution

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

Code Snippets

DECLARE @StartTime1 datetime 

SET @StartTime1 = GETDATE()

select query 1

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

GO

Context

StackExchange Database Administrators Q#70004, answer score: 5

Revisions (0)

No revisions yet.