View Full Version : Trigger Question: select from deleted


Kodo
01-17-2006, 12:19 PM
ok, I have a trigger set up to grab a value from the deleted table


ALTER TRIGGER ECShipment_Update_Cartmember
ON dbo.ECShipment
FOR DELETE
AS

DECLARE @cartmemberid bigint

set @cartmemberid=(SELECT top 1 shipment_cartmemberid from DELETED)

exec spECMergeCartMembers @cartmemberid


the delete method I'm using uses DELETE FROM [table] WHERE [field] IN(list of id's)

now, I've figured out the hard way that the trigger only fires on one event not on every row deletion. So I have to select one value from the deleted table and I thought I could use the above to accomplish this. The id that gets returned is irrelevant so long as I can get one returned (yes, there is a bit of necessary denormalization). My problem is that the trigger won't return any values. Any one have any clue how I go about this? (SQLHell?)

Thanks in advance! :)

SQL_Hell
01-20-2006, 03:00 AM
Hi there,

Just having a look at this, but I dont plan to be on this forum much for the next week or so. Can you Pm me and I will give you my personal email address

Cheers mate

SQL_hell

SQL_Hell
01-26-2006, 07:28 AM
Hi Kodo

Did you get this sorted out? I have been thinking you should get rid of the trigger entirely, and group everything into one stored procedure.

Let me know if you need more help

Kodo
01-26-2006, 08:32 AM
yes, I did. I tried emailing you but the address you pm'd me bounced.
In any case, I ended up resolving this by making a further normalization to my db and running the deletes on the table while leaving the parent record intact which is was I wanted to simulate .. alas, that night I had a brain fart and mapped it out the next day. :)

SQL_Hell
01-27-2006, 01:19 AM
excellent mate :) I'm glad you had a brain fart and sorted it out :D

Sorry I couldn't be much help