Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 28th, 2006, 01:07 AM
sadaf sadaf is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Posts: 1 sadaf User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m 15 sec
Reputation Power: 0
Getting query processing time

I want to get the time it takes to run a query.
Is there a way to get it ? for example a system variable or stored proc ?
I can get the "current time" before and after the query, and subtract them, but I want only the "time" part, and I want to Insert the time in a column of a table.
how can I do it ?

Reply With Quote
  #2  
Old June 30th, 2006, 05:19 AM
eralpery eralpery is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2006
Posts: 16 eralpery User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 19 m 57 sec
Reputation Power: 0
Hi,

I created a table b for storing query execution information as below

create table b (
id int identity(1,1),
time_in_ms bigint,
query ntext
)

GO


Then I prepared the query and the execution time calculations in the following statements

declare @s datetime
declare @e datetime
declare @sql nvarchar(4000)

select @s = getdate(), @sql = N'select * from Octopus..RIS'
exec sp_executesql @sql
select @e = getdate()
insert into b select datediff(ms,@s,@e), @sql

You can see the results in milliseconds stored in the table b

select * from b


Eralper
http://www.kodyaz.com

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft SQL Server > Getting query processing time


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT