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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 INSERT query execution time
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

5 Posts

Posted - 11/07/2010 :  07:09:51  Show Profile  Reply with Quote

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

Any help would be greatly appreciated.

Flowing Fount of Yak Knowledge

8781 Posts

Posted - 11/07/2010 :  07:34:28  Show Profile  Visit webfred's Homepage  Reply with Quote
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

Flowing Fount of Yak Knowledge

2937 Posts

Posted - 11/07/2010 :  09:20:41  Show Profile  Reply with Quote
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.


Go to Top of Page

Starting Member

1 Posts

Posted - 11/07/2010 :  15:45:48  Show Profile  Reply with Quote
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000