SprocKing says: "I implemented audit triggers on tables with both text and image columns in them. The problem is that you can't refer to binary columns in the inserted and deleted tables."
here is an additional issue with the article.
1. Instead of triggers overright your update statement and you can't refer blob columns. That means you have no mechanism of updating the blob column through instead of triggers.
2. let em clarify on what I mentioned. If you update the blob fields using UPADTETEXT or WRITETEXT, triggers will not fire. Triggers will fire only if you update them through Update statement. (If you disagree check the example give here.) That means Audit trigger is not a reliable solution if you have ad-hoc queries and blob columns.
Here is the example.
I am using SQL Server 2000 Sp4 with all the latest hotfixes.
IF Object_ID('TriggerTest') is NOT NULL
Drop table TriggerTest
GO
Create table TriggerTest
(
IntID int identity(1,1) primary key clustered,
Field1 varchar(20) not NULL,
Field2 text NOT NULL Default(''),
Last_Modified datetime NOT NULL default(GetDate())
)
GO
Create Trigger trg_TriggerTest_Ins_Upd On TriggerTest INSTEAD of Update
As
Update TriggerTest Set
Field1 = IsNULL(I.Field1, TriggerTest.Field1),
Last_Modified =CURRENT_TIMESTAMP
From Inserted I
Where I.IntID = TriggerTest.IntID
GO
Set IDENTITY_INSERT TriggerTest ON
Insert TriggerTest (IntID, Field1) Values(1, 'Record 1')
Set IDENTITY_INSERT TriggerTest OFF
Select * from TriggerTest
WAITFOR DELAY '00:00:00.500'
Update TriggerTest Set Field2 ='Row 1' Where IntID =1
Select * from TriggerTest
WAITFOR DELAY '00:00:00.500'
DECLARE @ptrval binary(16)
SELECT @ptrval = TEXTPTR(Field2)
FROM TriggerTest
WHERE IntID =1
WRITETEXT TriggerTest.Field2 @ptrval 'The text column for row 1 is added through WRITETEXT.'
Select * from TriggerTest
WAITFOR DELAY '00:00:00.500'
Declare @LEN int
SELECT @ptrval = TEXTPTR(Field2), @Len= DataLength(Field2)
FROM TriggerTest
WHERE IntID =1
UPDATETEXT TriggerTest.Field2 @ptrval @LEN 0 ' The text column for row 1 is updated through UPDATETEXT'
Select * from TriggerTest
WAITFOR DELAY '00:00:00.500'
Update TriggerTest Set Field1 ='record1' Where IntID =1
Select * from TriggerTest
Cheers,
Prithiviraj Kulasingham
http://preethiviraj.blogspot.com/