Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-05-09
2
Medium Priority
?
582 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 1500 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
I have a large data set and a SSIS package. How can I load this file in multi threading?
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

705 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