Solved

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

Posted on 2013-05-09
2
575 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
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how the fundamental information of how to create a table.

810 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