sends an email when an insert or delete occurs on the discounts table. : xp_sendmail « System Settings « SQL Server / T-SQL Tutorial

SQL Server / T-SQL Tutorial
1. Query
2. Insert Delete Update
3. Table
4. Table Join
5. Data Types
6. Set Operations
7. Constraints
8. Subquery
9. Aggregate Functions
10. Date Functions
11. Math Functions
12. String Functions
13. Data Convert Functions
14. Analytical Functions
15. Sequence Indentity
16. View
17. Index
18. Cursor
19. Database
20. Transact SQL
21. Procedure Function
22. Trigger
23. Transaction
24. XML
25. System Functions
26. System Settings
27. System Tables Views
28. User Role
29. CLR
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
SQL Server / T-SQL Tutorial » System Settings » xp_sendmail 
26. 46. 1. sends an email when an insert or delete occurs on the discounts table.
4>
5>
6CREATE TABLE discounts(
7>    discounttype   varchar(40)       NOT NULL,
8>    stor_id        char(4NULL              ,
9>    lowqty         smallint              NULL,
10>    highqty        smallint              NULL,
11>    discount       dec(4,2)          NOT NULL
12)
13> GO
1>
2insert discounts values('Initial Customer',  NULL,   NULL, NULL, 10.5)
3insert discounts values('Volume Discount',   NULL,   100,  10006.7)
4insert discounts values('Customer Discount', '8042', NULL, NULL, 5.0)
5> GO

(rows affected)

(rows affected)

(rows affected)
1>
2>     CREATE TRIGGER trDiscounts_InsDel ON discounts
3>     FOR INSERT, DELETE
4>     AS
5>     DECLARE @intRowCount INTEGER,
6>         @chvMsg VARCHAR(255)
7>     SELECT @intRowCount = @@RowCount
8>     SELECT @chvMsg = CONVERT(VARCHAR(10), @intRowCount ' record(swere '
9>     SELECT COUNT(*FROM inserted
10>     IF @@error <> 0
11>         SELECT @chvMsg = @chvMsg + ' deleted from the discounts table.'
12>     ELSE
13>         SELECT @chvMsg = @chvMsg + ' inserted into the discounts table.'
14>     EXEC master..xp_sendmail 'Colleen', @chvMsg
15>     RETURN
16>     GO
1>
2>     drop trigger trDiscounts_InsDel;
3>     GO
1>
2>
3> drop table discounts;
4> GO
26. 46. xp_sendmail
26. 46. 1. sends an email when an insert or delete occurs on the discounts table.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.