I would like to run a query to see when and by whom the DBO of a particular database was changed. How should I do it?
I found this information about stackexchange ... and tried, and it worked. The only problem was that he only gave me the user who changed DBO for the last time, not the time before. I was the one who changed DBO for the last time because my application did not work. I need to know who changed DBO before that time. Does anyone know how I will do this - find the last couple of times when the DBO was modified and by whom? This is the code that lets me know who changed it the last time:
. sp_changedbowner , :
:: [foo] [bar] :
DECLARE @path NVARCHAR(260); SELECT @path = REVERSE(SUBSTRING(REVERSE([path]), CHARINDEX('\', REVERSE([path])), 260)) + N'log.trc' FROM sys.traces WHERE is_default = 1; SELECT * -- whittle down to the meaningful trace columns FROM sys.fn_trace_gettable(@path, DEFAULT) WHERE EventClass = 152 ORDER BY StartTime DESC;
-, .
, ...
sys.traces , SQL. , . defaul trace log_000.trc. . LOG, SQL ERRORLOG, .
sys.traces
log_000.trc
, , , . , 20 . , , . , , , , , , .
, , , , . , sys.fn_trace_gettable() ; - , , . , , , , , .
sys.fn_trace_gettable()