If you have default traces enabled ( should be the sqlserver default unless your installation dated pre RTM ), you can find information what extended your (temp)db.
/*
* Import Default Trace
*/
/*
* read SQL default trace file name
*/
SET nocount ON
declare @wrkTraceFilename nvarchar(500)
-- read trace info
SELECT @wrkTraceFilename = convert(nvarchar(500), [value])
FROM fn_trace_getinfo(1) -- 1 = default trace
where [property] = 2
-- Property
-- 1 = Trace options. For more information, see @options in sp_trace_create (Transact-SQL).
-- 2 = File name
-- 3 = Max size
-- 4 = Stop time
-- 5 = Current trace status
print @wrkTraceFilename
if object_id('tempdb..#tmpTrace') is not null
begin
drop table #tmpTrace
end
select *
-- used this to be sure I have ALL available columns ( never mind edition, servicepack, CU, HF, ...)
into #tmpTrace
from fn_trace_gettable(@wrkTraceFilename, default)
;
/* Show unfiltered trace data
Select TE.name as EventName
, db_name(T.DatabaseID) as DatabaseName0
, T.HostName as TheHostName
, T.ApplicationName as TheApplicationName
, T.LoginName as TheLoginName
, T.StartTime as TheStartTime
, T.EndTime as TheEndTime
, Object_schema_name(T.ObjectID, T.DatabaseID) as TheObjectSchema
, Object_name(T.ObjectID, T.DatabaseID) as TheObjectName
, T.ServerName as TheServername
, T.*
from #tmpTrace T
inner join sys.trace_events TE
on TE.trace_event_id = T.EventClass
order by TheStartTime
, DatabaseName
, LoginName
, HostName
, ApplicationName ;
*/
/* Show Auto Grow events */
Select TE.name as EventName
, T.StartTime
, T.EndTime
, T.Duration/* in microseconds ! */
, DatabaseName
, FileName
, T.LoginName
, T.HostName
, T.ApplicationName
, T.ServerName
, T.SessionLoginName
from #tmpTrace T
inner join sys.trace_events TE
on TE.trace_event_id = T.EventClass
Where TE.name in ('Data File Auto Grow',
'Log File Auto Grow')
order by StartTime desc
;
If @@rowcount = 0
begin
Select 'No Auto Grow events occurred in the loaded default trace file. (hence empty result set in previous query)' as Remark
end
/* Show only where objects involved */
Select TE.name as EventName
, Object_schema_name(T.ObjectID, T.DatabaseID) as TheObjectSchema
, Object_name(T.ObjectID, T.DatabaseID) as TheObjectName
, T.*
from #tmpTrace T
inner join sys.trace_events TE
on TE.trace_event_id = T.EventClass
Where Object_name(ObjectID, DatabaseID) is not null
order by T.StartTime
, TheObjectSchema
, TheObjectName
;
/*
drop table #tmpTrace
*/
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me