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 |
|
BlackenedCatfish
Starting Member
3 Posts |
Posted - 2011-11-29 : 13:03:55
|
| Hi,I have the following trigger:CREATE TRIGGER table_copyON MailOrderManager.dbo.FDXFOR InsertASBEGININSERT INTO MailOrderManager.dbo.FDX_TRANSFER SELECT * FROM MailOrderManager.dbo.FDXENDGOI need to add an IF EXISTS condition that compares the value in column FDX_ID located in MailOrderManager.dbo.FDX to the same column name in MailOrderManager.dbo.FDX_TRANSFER. How can I do that as easily as possible? I'm really new to SQL, only did some of it back in school years ago and need to make this little trigger work without creating a ton of dupes.Thanks for any help! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-29 : 13:05:44
|
| you should be using INSERTED table instead of MailOrderManager.dbo.FDX------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
BlackenedCatfish
Starting Member
3 Posts |
Posted - 2011-11-29 : 13:13:06
|
quote: Originally posted by visakh16 you should be using INSERTED table instead of MailOrderManager.dbo.FDX------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Hi Visakh,Like I mentioned beforehand, I really don't know much SQL at all. Could you please explain what you mean?Thanks! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-29 : 13:16:05
|
| [code]CREATE TRIGGER table_copyON MailOrderManager.dbo.FDXFOR InsertASBEGININSERT INTO MailOrderManager.dbo.FDX_TRANSFER SELECT * FROM INSERTEDENDGO[/code]this will make sure only newly inserted records gets inserted in other table as well------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
BlackenedCatfish
Starting Member
3 Posts |
Posted - 2011-11-29 : 13:52:49
|
quote: Originally posted by visakh16
CREATE TRIGGER table_copyON MailOrderManager.dbo.FDXFOR InsertASBEGININSERT INTO MailOrderManager.dbo.FDX_TRANSFER SELECT * FROM INSERTEDENDGO this will make sure only newly inserted records gets inserted in other table as well------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Excellent, thank you. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-30 : 01:33:59
|
| wc------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|