Capture SHRINKFILE execution

  • Is there a way to capture who and when someone runs a shrinkdb/shrinkfile on a database short of running a trace?

  • I think the default trace that is running in SQL Server will capture this information.

    --Run this query to get the current file name and place it in the path for the query below

    SELECT * FROM ::fn_trace_getinfo(0)

    SELECT *

    FROM ::fn_trace_gettable('E:\SQLData\MSSQL10.MSSQLSERVER\MSSQL\Log\log_21.trc',0)

    INNER JOIN sys.trace_events e

    ON eventclass = trace_event_id

    INNER JOIN sys.trace_categories AS cat

    ON e.category_id = cat.category_id

    Here is an article that will help explain it a little more.

    http://www.sqlservercentral.com/articles/SQL+Server+2005/64547/

  • Ken Simmons, you are a genius. Sadly enough, I spent quite some time googling on this to no avail. Clearly I wasn't searching for the right thing..

    Thanks again.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply