CREATE TRIGGER [dbo].[KNMT_LOG] ON [dbo].[KNMT] FOR UPDATE, DELETE AS DECLARE @CLIENT AS VARCHAR(50) DECLARE @DATE AS VARCHAR(8) DECLARE @TIME AS VARCHAR(8) DECLARE @USERNAME AS VARCHAR(50) DECLARE @STATMT AS VARCHAR(max) DECLARE @strSQL AS VARCHAR(100) SET @CLIENT = HOST_NAME() SET @DATE = CONVERT(VARCHAR(8),GETDATE(),112) SET @TIME =REPLACE(CONVERT(VARCHAR(8),GETDATE(),108),':','') SET @strSQL='DBCC INPUTBUFFER('+CAST(@@SPID AS VARCHAR(50))+')' CREATE TABLE #STATEMENT (C1 VARCHAR(50),C2 VARCHAR(50),C3 VARCHAR(5000)) INSERT INTO #STATEMENT EXEC(@strSQL) SELECT @STATMT=C3 FROM #STATEMENT INSERT INTO LOGR(USERID,STRSQL,DATE,TIME,TABLNM) VALUES(@CLIENT,@STATMT,@DATE,@TIME,'KNMT') GO