Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Can a query time itself?

Author  Topic 

sbt1
Yak Posting Veteran

89 Posts

Posted - 2004-07-01 : 14:09:22
Can I run a query, and have the query return the amount of time it takes to execute it, instead of (or in addition to would be ok) the actual data requested?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-07-01 : 16:31:21
DECLARE @StartTime datetime

SET @StartTime = GETDATE()

-- query goes here

SELECT DATEDIFF(ms, @StartTime, GETDATE())

Tara
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-07-01 : 16:33:28
Remember..that's "wall time" (do they still say that)

Has some meaning, but doesn't tell the whole picture though...



Brett

8-)
Go to Top of Page

JimL
SQL Slinging Yak Ranger

1537 Posts

Posted - 2004-07-01 : 16:43:41
Its just another Brick.

Jim
Users <> Logic
Go to Top of Page

kselvia
Aged Yak Warrior

526 Posts

Posted - 2004-07-01 : 16:56:37
You can also run

set statistics time on

and SQL will return the time it took to compile and execute queries
Go to Top of Page
   

- Advertisement -