Code Snippet
--check if default trace is enabled
select * from sys.configurations where configuration_id = 1568
--get the current trace rollover file
--use this path with the log.trc file in the path below.
--this will cause a file rollover to get all the data
select * from ::fn_trace_getinfo(0)
--list of events object deleted, object altered
select *
from sys.trace_events
--list of categories e.g. database, sp etc..
select *
from sys.trace_categories
SELECT ntusername,loginname, objectname, e.category_id, textdata, starttime,spid,hostname, eventclass,databasename, e.name
FROM ::fn_trace_gettable('C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\log.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
where databasename = 'MyDB' and
objectname = 'MySpName' and
cat.category_id = 5 and --category objects
e.trace_event_id = 46 --object creation