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 |
|
doran_doran
Posting Yak Master
179 Posts |
Posted - 2009-12-08 : 11:23:56
|
| How is this looking?CREATE TRIGGER [it_Orders_to_FillOrders]ON [Orders]FOR INSERTASBEGIN TRYINSERT INTO [FillOrders].[dbo].[tblFillOrders](orderid,orderprice,orderdesc,quantity)SELECTo.orderid,o.orderprice,od.description,o.quantityFROM orders oleft outer join OrdersDescription odon o.orderid = od.OrderIDEND TRYDECLARE @runDateTime datetime = GETDATE(),@UserName varchar(100) = system_userBEGIN CATCHINSERT INTO [FillOrder].[dbo].[logs](username,logdatetime,tablename,useraction,COMMENT)VALUES (@UserName,@runDateTime,'tblFillOrders','Insert','Attempt Failed')RETURN 1END CATCH-- Rollback the transaction if there were any errorsIF @@ERROR <> 0BEGINROLLBACK -- ROLLBACK THE TRANSACTIONRETURN 0END |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-12-08 : 11:25:34
|
| Did you see tara's reply from here?http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=136725 |
 |
|
|
|
|
|
|
|