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.
| Author |
Topic |
|
umapathy
Starting Member
24 Posts |
Posted - 2007-12-04 : 22:03:04
|
Hi folkshow to fire a trigger when i delete record from a table.for example , i have a two tablesemp1,empemp1empid departmentx salesy productionemp empid] name age addressx john 25 APY Peter 30 TNin this above two table if i delete record from emp1 the trigger should fire and then it should delete a relevent record form the emp table.how should i achieve this?can any one help this.umapathy  |
|
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2007-12-04 : 23:18:50
|
| To do that you shouldn't use a trigger, use a FOREIGN KEY constraint with cascading delete. Here's the docs on cascading referential integrity constraintshttp://msdn2.microsoft.com/en-us/library/ms186973.aspxIf you really want to use triggers (not recommended) then look up the CREATE TRIGGER statement. |
 |
|
|
umapathy
Starting Member
24 Posts |
Posted - 2007-12-05 : 00:44:03
|
| Thanks |
 |
|
|
|
|
|