Any updates done to my table I would like them to be logged. So I decided to search it up and came across creating Database triggers. I followed a tutorial and I was successfully able to log any ALTERS done to tables but any UPDATES done aren't being logged. Followed this Tutorial: https://jackworthen.com/2018/03/19/creating-a-log-table-to-track-changes-to-database-objects-in-sql-server/
Query:
CREATE TRIGGER [backup_objects]
ON DATABASE
FOR CREATE_PROCEDURE,
ALTER_PROCEDURE,
DROP_PROCEDURE,
CREATE_TABLE,
ALTER_TABLE,
DROP_TABLE,
CREATE_FUNCTION,
ALTER_FUNCTION,
DROP_FUNCTION,
CREATE_VIEW,
ALTER_VIEW,
DROP_VIEW
AS
SET NOCOUNT ON
DECLARE @data XML
SET @data = EVENTDATA()
INSERT INTO [dbo].UserChangelog(databasename, eventtype,
objectname, objecttype, sqlcommand, loginname)
VALUES(
@data.value('(/EVENT_INSTANCE/DatabaseName)[1]', 'varchar(256)'),
@data.value('(/EVENT_INSTANCE/EventType)[1]', 'varchar(50)'),
@data.value('(/EVENT_INSTANCE/ObjectName)[1]', 'varchar(256)'),
@data.value('(/EVENT_INSTANCE/ObjectType)[1]', 'varchar(25)'),
@data.value('(/EVENT_INSTANCE/TSQLCommand)[1]', 'varchar(max)'),
@data.value('(/EVENT_INSTANCE/LoginName)[1]', 'varchar(256)')
)
GO
I thought the trigger was missing, "UPDATE_TABLE" but that unfortunately doesn't even exist.
Anyone got an idea of what I might have to add to my trigger? I technically don't need it to be focused on the entire Database but that's just a bonus.