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 |
|
tradingpassion
Starting Member
24 Posts |
Posted - 2005-07-21 : 21:23:04
|
| I m trying to create a Trigger that will trigger and will send an email when new product is added the first time because there is a possibility that the same product might will get added the second time and I do not want to send an emailWhat will be best way to implement this? |
|
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2005-07-21 : 21:27:19
|
| You can do a check within the trigger to see if the record has already been created. Then you can use the xp_sendmail SP to send the email.HTH,Tim |
 |
|
|
tradingpassion
Starting Member
24 Posts |
Posted - 2005-07-21 : 21:52:38
|
| I know how to create triggers and stuff and have worked with xp_sendmail but not sure how to check within the trigger to see if the record has already been created?So when the record gets added first time then I want to send an email but when the same record gets added again then I do not want to send an email |
 |
|
|
byrmol
Shed Building SQL Farmer
1591 Posts |
Posted - 2005-07-21 : 21:59:03
|
| [code]So when the record gets added first time then I want to send an email but when the same record gets added again then I do not want to send an email[/code]...SHUDDER.... Do you have a key on this table or is it a bag (has duplicates)?Why not COUNT?DavidMA front-end is something that tries to violate a back-end. |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2005-07-21 : 22:25:12
|
i believe this answers your question...quote: Originally posted by timmy You can do a check within the trigger to see if the record has already been created. Then you can use the xp_sendmail SP to send the email.HTH,Tim
for the how to do, query through the table and join with the 'inserted' table to determine if records are identical using group by?--------------------keeping it simple... |
 |
|
|
|
|
|