Wednesday 16 October 2013

02. The management of AdventureWorks Incorporation has decided that no user should be able to change the prices of products. In addition, the management wants that all the attempts to change the price should be saved in a temporary table, Temp. John, the Database Developer, has been asked to make significant changes in the database to implement this policy. What should John do to achieve the same?

create Table Temp
(
ProductID int,
AttChangeCost money,
AttTime datetima
)


create trigger updtrigger on
Production.ProductCostHistory insert of UPdate
as
Begin
declare @Pid as int
Declare @cost as money
select @pid=ProductID,
@cost=standardCost from Deletedinsert into Temp values(@Pid,@cost,getdate())
select 'sorry you can not change the price of a product'
end


update Production.ProductCostHistory
set standardCost=55
where productID=707

No comments:

Post a Comment