Solved

How Long DBCC Shrinkdatabase command took to run last week on SQL server ent 2008 R2?

Posted on 2013-05-09
2
579 Views
Last Modified: 2013-05-10
hello guys,

i had a collegue run the command DBCC SHRINKDATABASE(dbname,10) last week on my SQL server 2008 R2 on saturday and my collegue told me it ran successfully but forgot to let me know how long it took to run. Today i'm back at work and its is thursday and i want to find out how long it took to run. I ran the following Query to try to find out how long DBCC SHRINKDATABASE took to run but i'm not able to find DBCC SHRINKDATABASE query anywhere, i also looked at SQL logs/error logs and there is nothing there. IS there anyway to find out how long it took? any help will be appreciated.


SELECT DISTINCT TOP 100
t.TEXT QueryName,
s.execution_count AS ExecutionCount,
s.max_elapsed_time AS MaxElapsedTime,
ISNULL(s.total_elapsed_time / s.execution_count, 0) AS AvgElapsedTime,
s.creation_time AS LogCreatedOn,
ISNULL(s.execution_count / DATEDIFF(s, s.creation_time, GETDATE()), 0) AS FrequencyPerSec
FROM sys.dm_exec_query_stats s
CROSS APPLY sys.dm_exec_sql_text( s.sql_handle ) t
ORDER BY
s.max_elapsed_time DESC
GO
0
Comment
Question by:Cholo123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 30

Accepted Solution

by:
Rich Weissler earned 500 total points
ID: 39155701
Hmm.  I can't find one.
I can see the event in the default trace:
SELECT  t.TextData, t.clientprocessID, t.Duration , t.StartTime , t.EndTime
FROM    sys.fn_trace_gettable(CONVERT(VARCHAR(150), ( SELECT TOP 1 f.[value]
                                                      FROM    sys.fn_trace_getinfo(NULL) f
                                                      WHERE   f.property = 2
                                                    )), DEFAULT) T
 WHERE   t.eventclass = 116

Open in new window

Will return all the DBCC events in the current default trace, and you can adjust the file pulled to look at the others.  Unfortunately that really only gives the start time.  I suppose if your colleague ran another query from the same query window after the Shrinkfile finished... you'd be able to look at the starttime of their next command and extrapolate the amount of time it took.  *shrugs.sadly*
0
 

Author Comment

by:Cholo123
ID: 39156765
oh man that sucks. he didnt run any other query. bummer thanks for your input appreciated.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question