Click here to Skip to main content
14,733,966 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello All ,

I have one table in sql server called as employee which has empid and empname as columns

I have trigger in place which will log in employee changes history.

I have one stored procedure and below are the queries in the SP

1) Delete from Employee where Empid=@Empid
2) Insert Into Employee SELECT @Empid,@EmpName
3) Delete from Employee where Empname=@EmpName


I know above three statement is not meaning full but Above is just an example to sort the understanding.

Now I want "some changes" while executing the first statement where "Delete Trigger" will not fire.
But I want it to be fired on third delete query .
Posted

1 solution

I would think you need to create a table that stores a count, unless there's a variable mechanism in SQL Server, then increment your counter and when it gets to three, perform your action. I expect you'll put this code inside your trigger, so it always fires, but only acts when you want it to.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900