Use CommunityAssist
go
Create trigger tr_FlaggedDonations
on Donation after insert
As
Declare @donationAmount money
Select @donationAmount =DonationAmount
From Inserted
if @donationAmount > 10000
Begin
if not exists
(Select name from sys.tables
Where name='FlaggedDonations')
Begin
Create table FlaggedDonations
(
DonationKey int,
DonationDate datetime,
DonationAmount money,
PersonKey int,
EmployeeKey int
)
End
Insert into FlaggedDonations(
DonationKey,
DonationDate,
DonationAmount,
PersonKey,
EmployeeKey)
Select DonationKey,
DonationDate,
DonationAmount,
PersonKey,
EmployeeKey
From Inserted
Print 'Large Donation recieved'
End
Select * from FlaggedDonations
Wednesday, February 27, 2013
Our trigger example
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment