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
 General SQL Server Forums
 New to SQL Server Programming
 INSERT query execution time

Author  Topic 

cjjubb
Starting Member

5 Posts

Posted - 2010-11-07 : 07:09:51
Hi

Does anybody know how to insert the query execution time (into a field) as part of a query?

Any help would be greatly appreciated.

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-11-07 : 07:34:28
I've never heard or seen something like this.
IMHO a column of a resultset of a query isn't qualified for a value like this because each row in a resultset would have another duration.
In fact the execution time is a single value that has no place in the result set of a query.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-11-07 : 09:20:41
You can do the following.Before your actual query declare a variable of datatype datetime say @dt and set its value to getdate().after the actual query statement you can write something like this

select 'query time'=datediff(second,@dt,getdate())

which gives you the execution time which can be inserted in the desired table.

PBUH

Go to Top of Page

maryrwallace
Starting Member

1 Post

Posted - 2010-11-07 : 15:45:48
unspammed
Go to Top of Page
   

- Advertisement -