Trigger Question: select from deleted

Kodo

"The Shoe"
Local time
Yesterday, 23:23
Joined
Jan 20, 2004
Messages
707
ok, I have a trigger set up to grab a value from the deleted table

Code:
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
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! :)
 
Last edited:
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
 
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
 
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. :)
 
excellent mate :) I'm glad you had a brain fart and sorted it out :D

Sorry I couldn't be much help
 

Users who are viewing this thread

Back
Top Bottom