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 |
|
jportnoy
Starting Member
7 Posts |
Posted - 2007-05-29 : 11:32:41
|
SQL newbie question =(Table A: field1Table B: field1field2I'm trying to create a SQL trigger that deletes all records in B where (B.field1 = A.field1) when a record is inserted into Table A.I have this:CREATE TRIGGER tgMyTrigger ON TableA FOR INSERTAS BEGIN DELETE FROM TableB WHERE (TableB.field1 = Inserted.field1)ENDGOI keep getting "The multi-part identifier "Inserted.field1" could not be bound."I had this trigger working on Friday, but I was trying to rush out of the office and accidently deleted it.  |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-05-29 : 11:35:19
|
| [code]Delete BFrom TableB B Join Inserted Ion B.Field1 = I.Field1[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
arvind
Starting Member
12 Posts |
Posted - 2007-05-30 : 17:53:45
|
| hitry thisCREATE TRIGGER tgMyTriggerON TableAFOR INSERTAS BEGINDELETE FROM TableBWHERE (TableB.field1 = (Select field1 from Inserted))ENDGO |
 |
|
|
aravindt77
Posting Yak Master
120 Posts |
Posted - 2007-06-01 : 06:17:28
|
| HI TRY OUT FOR THIS,,,,CREATE TRIGGER TEST_TRIGGER ON AFOR INSERT AS0BEGINDELETE FROM BWHERE COL2 IN (SELECT DISTINCT COL2 FROM INSERTED)PRINT ' OK'ENDPLZ GO THRU IT ...FOUND SUCCESS IN MY TEST CASE |
 |
|
|
|
|
|