Solved

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

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

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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now