June 30, 2015 at 9:59 pm
How can I easily identify who dropped a table?
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
June 30, 2015 at 10:29 pm
Thanks.
I saw the first article but I did not see where you identify the Login,
How do you read the transaction log?
The second Example may be easier.
Thanks again. 🙂
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
June 30, 2015 at 10:33 pm
I do not see where this code is reading a Transaction Log?
SELECT [Transaction Id], [Begin Time], SUSER_SNAME ([Transaction SID]) AS [User]
FROM fn_dblog (NULL, NULL)
WHERE [Transaction Name] = N’DROPOBJ';
GO
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
June 30, 2015 at 11:25 pm
July 1, 2015 at 2:59 pm
Welsh Corgi (6/30/2015)
I do not see where this code is reading a Transaction Log?
SELECT [Transaction Id], [Begin Time], SUSER_SNAME ([Transaction SID]) AS [User]
FROM fn_dblog (NULL, NULL)
WHERE [Transaction Name] = N’DROPOBJ';
GO
The fn_dblog function is what reads the log.
Cheers!
July 1, 2015 at 4:19 pm
Jacob Wilkins (7/1/2015)
Welsh Corgi (6/30/2015)
I do not see where this code is reading a Transaction Log?
SELECT [Transaction Id], [Begin Time], SUSER_SNAME ([Transaction SID]) AS [User]
FROM fn_dblog (NULL, NULL)
WHERE [Transaction Name] = N’DROPOBJ';
GO
The fn_dblog function is what reads the log.
Cheers!
Thanks a lot. 🙂
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
July 2, 2015 at 5:42 am
July 2, 2015 at 8:46 am
If the default trace is enabled (which is should be), then that can be used to query DDL events, including more information about the session and user than what the transaction log offers.
SELECT DISTINCT
gt.StartTime
,e.[Name] EventName
,gt.[ObjectName]
,gt.SPID
,gt.[HostName]
,gt.[LoginName]
,gt.[ApplicationName]
,ec.client_net_address
FROM fn_trace_gettable(
(
SELECT cast(value as varchar(8000))
FROM ::fn_trace_getinfo(0)
where traceid = 1 and property = 2), DEFAULT
) gt
JOIN sys.trace_events e ON gt.eventclass = e.trace_event_id
LEFT JOIN sys.dm_exec_connections EC On EC.session_id = gt.SPID
WHERE gt.starttime > dateadd(hour,-48,GETDATE())
AND e.Name like 'Object:Deleted'
ORDER BY gt.starttime desc;
"Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply