I need to detect renaming operation on columns and tables.
I can see alter, drop and create operation in this query:
DECLARE @filename nvarchar(1000);
SELECT @filename = cast(value as nvarchar(1000))
FROM ::fn_trace_getinfo(default)
WHERE traceid = 1 and property = 2;
SELECT *
FROM fn_trace_gettable(@filename, default) AS ftg
INNER JOIN sys.trace_events AS te ON ftg.EventClass = te.trace_event_id
left outer join sys.all_objects o on o.name = ftg.ObjectName
order by EventSequence DESC;
But when someone renames a table or column on MSSQL Management Studio, I cannot detect on this query. Is there another way to do it?
Regards.
You can create a database trigger. List of available events:
[sys].[events](there areALTER_COLUMNevent)Example from msdn:
another example: https://www.mssqltips.com/sqlservertip/2085/sql-server-ddl-triggers-to-track-all-database-changes/