Trigger Code on a table in my ERP Database
Posted
by David Stein
on Stack Overflow
See other posts from Stack Overflow
or by David Stein
Published on 2010-03-23T19:14:03Z
Indexed on
2010/03/23
19:23 UTC
Read the original article
Hit count: 427
sql-server-2000
|tsql
My ERP Vendor has the following trigger on a table:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TRIGGER [dbo].[SOItem_DeleteCheck]
ON [dbo].[soitem]
FOR DELETE
AS
BEGIN
DECLARE @RecCnt int, @LogInfo varchar(256)
SET @RecCnt = (SELECT COUNT(*) FROM deleted)
IF @RecCnt > 150
BEGIN
RAISERROR (54010, 18, 1, 'SOItem') WITH LOG
ROLLBACK TRANSACTION
END
SET @LogInfo = 'Deleting ' + LTRIM(STR(@RecCnt)) + ' Rows From SOItem'
EXEC LogDeletes @LogInfo
END
GO
This seems very inefficient to me. Doesn't select count(*) take longer than Count(specific field)?
© Stack Overflow or respective owner