April 28, 2009 at 8:14 am
Hello,
I've got a question... I want to see what sql or domain user has changed a stored procedure and when possible, from what machine.
Is this possible in sql 2005 enterprise?
Thanks in advance, and best regards,
Mischa E.J. Hoogendoorn
April 28, 2009 at 8:17 am
I would suggest setting up a DDL trigger and writing this to an audit table. If you are unsure how to implement this please let me know.
BJC
April 28, 2009 at 8:19 am
There is some info here, http://www.sqlservercentral.com/articles/SQL+Server+2005/64547/, but you you do want to set up auditing if that is an issue.
By default, only a limited amount of information is captured.
April 28, 2009 at 8:20 am
you can use the default trace, and hopefully find what happened;
here is aan example:
-- obtain file name for Default Trace
declare @TraceFileName nvarchar(256)
set @TraceFileName = (select path from sys.traces where is_default = 1)
-- get general name for Default Trace (remove rollover number)
set @TraceFileName =
substring (@Tracefilename, 1, (charindex ('\log_', @tracefilename) + 3)) + '.trc'
-- sample query: get info about recently added, deleted and modified
-- stored procedures in a database
select
ev.name
,tr.StartTime
,tr.DatabaseID
,tr.DatabaseName
,tr.ObjectID
,tr.ObjectName as 'Trace ObjectName'
,o.name as 'Sysobjects Name'
,o.type_desc
,tr.ObjectType
/* see 'ObjectType Trace Event Column' in BOL to get a translation of these type codes */
,sv.subclass_name as 'ObjectAbbrv'
,tr.LoginName
,tr.HostName
,tr.ApplicationName
from fn_trace_gettable(@TraceFileName, default) tr
join sys.trace_events ev
on tr.eventclass = ev.trace_event_id
join sys.trace_subclass_values sv
on tr.eventclass = sv.trace_event_id
and tr.ObjectType = sv.subclass_value
and sv.trace_column_id = 28
left join sys.objects o
on tr.ObjectID = o.object_id
where eventclass in (46, 47, 164) -- object created, deleted or altered
and eventsubclass = 1 -- only committed act
Lowell
April 28, 2009 at 8:49 am
Thanks you very much! That was exactly where I was looking for !
Thanks! 🙂
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply