Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 SQL Server Triggers

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-10-24 : 09:20:15
Seth writes "I need help writing a delete trigger. The table that I want to audit is [dbo].[MCMESSAGE]. When there is a delete on this table I want to write the deleted row to an audit table called [dbo].[AUDIT_MCMESSAGE]. The name of my trigger is [DEL_MCMESSAGE_TR].

This is what I have so far :

CREATE TRIGGER [DEL_MCMESSAGE_TR]
ON [dbo].[MCMESSAGE]
FOR DELETE AS
INSERT [dbo].[AUDIT_MCMESSAGE]

(MessageID, ReplyToID, Sender, Subject, CreateDate,
ExpirationDate, Reply, Body, ReadReceipt, Priority, Association,
AppID)

SELECT

MessageID, ReplyToID, Sender, Subject, CreateDate,
ExpirationDate, Reply, Body, ReadReceipt, Priority, Association, AppID

FROM deleted

When I test this I delete a record from [dbo].[MCMESSAGE] I get this Error :
"[Microsoft][ODBC SQL Server Driver][SQL Server]String or binary data would be truncated."

Could someone please hwlp me?"
   

- Advertisement -