Re: Killed by Triggers
- From: "Kalen Delaney" <replies@xxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 6 Feb 2008 16:12:54 -0800
Without seeing your DDL, my guess is that your have user names longer than
your CREATEDBY column was defined to hold.
What do you mean 'detail record was attempted'?
If a trigger fails, it will rollback the operation that caused the trigger
to be filed.
We really need more details here to give you more precise answers.
--
HTH
Kalen Delaney, SQL Server MVP
www.InsideSQLServer.com
http://blog.kalendelaney.com
"Will" <Will@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:9BEE2EB6-B81B-43F8-9701-A24FAADB604E@xxxxxxxxxxxxxxxx
Kalen, thanks for the quick reply.
The affected tables are a header/detail relationship. When trying to write
to the header table the error message was "String or Binary Data would be
truncated". When I removed the trigger the error disappeared.
The second situation is when a detail record was attempted, after the
header
record. The user gets no error, but the record is never written. Disabling
the triggers also resolved this issue.
Records are written through stored procedures and only 1 record is written
to each table in a transaction.
--
-Will
"Kalen Delaney" wrote:
Hi Will
What do you mean that users could not write to the tables? Do you get an
error? What does it say? If you don't get an error message, what are your
symptoms?
Please note that your trigger seems to assume that there will only be one
row inserted. You'll have problems if multiple rows are inserted in a
single
operation.
--
HTH
Kalen Delaney, SQL Server MVP
www.InsideSQLServer.com
http://blog.kalendelaney.com
"Will" <Will@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:100B4CDF-AD27-4E0B-AF30-DC40D4E55AB3@xxxxxxxxxxxxxxxx
I have INSERT and UPDATE triggers on my SQL2005 tables which record some
audit trail information. I noticed that they didn't seem to be working
so
I
reviewed them. They looked okay. I resaved them and carried on. They
used
to
work.
Then I found that users could no longer write to these tables. When I
disabled the triggers, users could again write records. A sample
trigger
is:
ALTER TRIGGER [tr_TABLE01_INSERT]
ON [dbo].[TABLE01]
AFTER INSERT
AS
BEGIN
DECLARE @ID AS INTEGER
SET NOCOUNT ON;
SELECT @ID = IDFIELD FROM inserted
IF @ID IS NOT NULL
UPDATE TABLE01 SET CREATEDBY = CURRENT_USER,
CREATEDATE = GETDATE()
WHERE IDFIELD = @ID
END
What could have I done to cause this?
--
-Will
.
- Follow-Ups:
- Re: Killed by Triggers
- From: Will
- Re: Killed by Triggers
- References:
- Re: Killed by Triggers
- From: Kalen Delaney
- Re: Killed by Triggers
- From: Will
- Re: Killed by Triggers
- Prev by Date: Re: Killed by Triggers
- Next by Date: Re: Killed by Triggers
- Previous by thread: Re: Killed by Triggers
- Next by thread: Re: Killed by Triggers
- Index(es):
Relevant Pages
|