I'm new to making triggers. I have the following trigger wich should delete a row in the Activity_Log table when I delete a row in the Poll_Comments table.... I have an error in my where clause - because it don't delete the specific row....
My trigger:ALTER TRIGGER [dbo].[deletePollCommentsTrigger]
DECLARE @intRowCount int
SELECT @intRowCount = @@RowCount
IF @intRowCount > 0
DELETE Activity_Log WHERE id IN (SELECT questionId FROM deleted) AND
activityDateCreated IN (SELECT commentsCreateDate FROM deleted) AND activitySectionPId = 8
If I change the statement to:
DELETE Activity_Log WHERE id IN (SELECT questionId FROM deleted) AND activitySectionPId = 8
It correctly deletes all rows with that specific questionId and where activitySectionPId = 8...
But I want also to have a where clause on, that ask for commentsCreateDate = activityDateCreated - so I only delete one row and not all rows...
How can I do that?
Kind regards,simsen :-)
View Complete Post