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 |
ggarza75
Yak Posting Veteran
50 Posts |
Posted - 2009-07-02 : 16:51:27
|
Need some syntax assistance.I have a Client Table that is tied in with Primary Contact Table by a foreign key. I have created a stored procedure that when a record with the client’s ID name is called with the SP, it copies the records to another database and deletes it from the Client and Primary Contact tables in Production.I have a third table called Secondary Contact, which has no key to the Client table. However it does have a key to the Primary Contact table.How can I have the records in the Secondary Contact table copy and delete when the records of the Primary Contact are copied and deleted?Thanks. I hope this was clear. |
|
TheSQLGuru
SQL Server MVP
10 Posts |
Posted - 2009-07-05 : 10:47:42
|
Your description was difficult to follow, but I think you need to check out Triggers in Books Online.Kevin G BolesTheSQLGuruIndicium Resources, Inc. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-07-05 : 13:00:19
|
As suggested, you need to have a triger like thisCREATE TRIGGER YourTriggerNameON [Primary Contact]AFTER DELETEASBEGINDELETE sFROM [Secondary Contact] sINNER JOIN DELETED dON d.keycolumn=s.keycolumnEND |
|
|
ggarza75
Yak Posting Veteran
50 Posts |
Posted - 2009-07-08 : 15:39:21
|
Thank you very much. This is what I needed. |
|
|
|
|
|