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-05-25 : 12:41:11
|
| Hi I am new to SQL and need help to figure out something...Basically what I am trying to do is creating a trigger so that whenever there is a new entry added in the table it copies the row and paste it paste it in the new table(new_table and from that table it will send an email to person abc@domain.comI got everything figured out including it's sending an email to abc@domain.com but the problem whenever there is a new customer added it sends an email with the list of all the new customers added previously from the(new_table) What I would like to do is send and email whenever there is a new customer added that particular day. For example if there is a new customer added (Customer A) on Monday April 5 at 10:00 am.I want to send an email to abc@domain.com that day only with Customer A AND if later in the day there is a new customer added(Customer B) on the same day around 11:00 am I would like to send an email again with Customer A and Customer B's information but if there is a new customer added on April 6th then I only want to send an email to xyz@domain.com with the list of customers added on April 6th and not April 5thI know you can probably do that using getdate() function or something but I am not sure how..and I beleive it has to be somewhere by the "IF" statement??OR I can use status field but I need help with implementing it but not sure how?ALTER TRIGGER Trigger1ON m_userFOR INSERTASINSERT Trigger_table(company_name, locn, user_id)SELECT company_name, locn, user_idFROM insertedif (select count(*) from sms..Trigger_Project where company_name='ABC') >0BEGINEXEC master..xp_sendmail @recipients = 'xyz@domain.com', @query = 'select * from dbs..Trigger_Table where company_name=''XYZ''', @subject = 'xyz',@message = 'New customer added today',@width = 350END |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
|
|
|
|
|