May 2, 2014 at 1:19 pm
I need help in creating a temporary table where I can log the QueryName, StartTime, Endtime, Duration
and run the Select query 100 times with to check the time
May 2, 2014 at 2:00 pm
saifmahatab (5/2/2014)
I need help in creating a temporary table where I can log the QueryName, StartTime, Endtime, Durationand run the Select query 100 times with to check the time
Pretty sparse on details here but something like this maybe? What are you hoping to accomplish by running the same query 100 times???
create table #MyTable
(
QueryName varchar(100),
StartTime datetime,
EndTime datetime,
Duration int --Do you really need this?
)
go
declare @StartTime datetime = getdate()
declare @EndTime datetime
select YourSelectmentHere
select @EndTime = getdate()
insert #MyTable
select 'YourQueryName', @StartTime, @EndTime, null
go 100
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
May 5, 2014 at 8:42 pm
Thanks but its not working..I tried I need to create a temp table where it stores the timing of a select query that I have takes time to run
May 6, 2014 at 2:57 am
saifmahatab (5/5/2014)
Thanks but its not working..I tried I need to create a temp table where it stores the timing of a select query that I have takes time to run
Sean's script works for me. Post yours, we'll see what's wrong.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply