patternsqlMinor
Print the execution time on messages Pane?
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
GoSolution
DATEDIFF will be useful
similarly do for other queries. @starttime2, 3
DECLARE @StartTime1 datetime
SET @StartTime1 = GETDATE()
select query 1
SELECT ExecutionTimeInMS = DATEDIFF(millisecond, @StartTime1, getdate())
GOsimilarly do for other queries. @starttime2, 3
Code Snippets
DECLARE @StartTime1 datetime
SET @StartTime1 = GETDATE()
select query 1
SELECT ExecutionTimeInMS = DATEDIFF(millisecond, @StartTime1, getdate())
GOContext
StackExchange Database Administrators Q#70004, answer score: 5
Revisions (0)
No revisions yet.