Text messages

The trigger in the following example sends e-mail to “purchasing” when an update causes the number of items on hand (onhand) in an inventory table (part) to fall below a certain level (min_onhand).

1> create trigger reorder
2> on part
3> for update as
4> if update(onhand)
5> if (select onhand - min_onhand 
6> from inserted <= 0
7> begin
8> execute xp_sendmail
9> @subject="Inventory Notice"
10> @recipient="purchasing"
11> @message="Parts need to be reordered."
12> end