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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Need Help in Trigger

Author  Topic 

hirani_prashant
Yak Posting Veteran

93 Posts

Posted - 2008-10-01 : 01:05:13
Hi All,

mmine table structure is as follows :-

Table Name OrderTable :-

PitId int NOT NULL,
BuySell nvarchar](10) NOT NULL,
Price float NOT NULL,
Size float NOT NULL,

Now i want to crete a trigger in such a way that if there is any updation in Price then it will send a mail to user with the updated price. Same way if there is any updation in size then it will send a mail to user with the updated size.

how can i able to do this?

Thanks
Prashant Hirani

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-01 : 01:20:28
I think the best approach would be to do this in the procedure whether you update the table. something like this

CREATE PROC UpdateOrder
AS
DECLARE @CHANGED_ORDERS
(Pit_Id int,
Old_Price float,
New_Price float
)

....other code
UPDATE Order
SET Price=newvalue,
...
OUTPUT INSERTED.pitid,DELETED.Price,INSERTED.Price INTO @CHANGED_ORDERS

--send mail to use

EXEC sp_send_dbmail....
GO


look into books online for syntax and usage of sp_send_dbmail

http://msdn.microsoft.com/en-us/library/ms190307.aspx
Go to Top of Page
   

- Advertisement -