SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

cjjubb
Starting Member

5 Posts

Posted - 11/07/2010 :  07:09:51  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

Germany
8683 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

Sachin.Nand
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.

PBUH

Go to Top of Page

maryrwallace
Starting Member

USA
1 Posts

Posted - 11/07/2010 :  15:45:48  Show Profile  Reply with Quote
unspammed
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.06 seconds. Powered By: Snitz Forums 2000