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 2005 Forums
 Transact-SQL (2005)
 database trigger

Author  Topic 

jgrant
Yak Posting Veteran

69 Posts

Posted - 2008-03-10 : 15:03:54
Is there a way to determine how many rows were deleted using a database trigger. I reviewed the sys.trigger_events but could not find where you might determine how many rows were deleted.

The Yak Village Idiot

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2008-03-10 : 15:18:33
Look at triggers, object identifiers in BOL:

DML trigger statements use two special tables: the deleted table and the inserted tables. SQL Server 2005 automatically creates and manages these tables. You can use these temporary, memory-resident tables to test the effects of certain data modifications and to set conditions for DML trigger actions. You cannot directly modify the data in the tables or perform data definition language (DDL) operations on the tables, such as CREATE INDEX.

Jim
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2008-03-10 : 15:20:43
@@rowcount as well!
Go to Top of Page

jgrant
Yak Posting Veteran

69 Posts

Posted - 2008-03-10 : 19:44:31
I have used @@rowcount before. How would you use @@rowcount within a database trigger?

The Yak Village Idiot
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-03-10 : 20:17:16
Just capture @@ROWCOUNT as the first line in your trigger.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

jgrant
Yak Posting Veteran

69 Posts

Posted - 2008-03-10 : 21:17:58
Thank you everyone.

The Yak Village Idiot
Go to Top of Page
   

- Advertisement -