Wednesday 16 October 2013

05. The management of AdventureWorks wants that whenever the account number of a user is modified, the old account number, as well as the new account number, should be instantaneously displayed to the user. How can you accomplish the desired task?

create Trigger Vendoraccountnum
on Purchasing.Vendor
for Update as
Begin
Declare @oldvalue nvarchar(15)
Declare @newvalue nvarchar(15)
select @oldvalue=Accountnumber from deleted
select @Newvalue=Accountnumber from inserted
print 'The old account number is'+@oldvalue
Print 'The New account number is'+Newvalue
end

No comments:

Post a Comment