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)
 Trigger Problem

Author  Topic 

kurtgr
Starting Member

25 Posts

Posted - 2009-07-10 : 21:15:20
Hello Experts

Below is my Delete Trigger

ALTER TRIGGER [dbo].[DeleteSkill] ON [dbo].[Skill] FOR DELETE
AS
BEGIN
IF EXISTS(SELECT 1
FROM EmployeeSkill
INNER JOIN Deleted ON EmployeeSkill.SkillId = Deleted.SkillId)
BEGIN
RAISERROR('Record already been used in related table(s). Delete failed!', 16,1)
ROLLBACK TRANSACTION
RETURN
END
END
Here is my problem when the condition hold true for the first time if get the message from the RAISERROR.

But say I click the delete button again without changing anything the trigger does not fire.

I am doing the delete from the table true a store procedure

Can you say if my trigger is missing something

Thank in advance

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-07-12 : 04:20:05
why are you doing this via trigger? its just a matter of setting foreign key reference from EmployeeSkill.SkillId to Skii.SkillId
Go to Top of Page
   

- Advertisement -