Create table TTemp----临时表
(
[NAME] varchar(20),
NRIC varchar(20),
PurseDescription varchar(20),
CardNumber varchar(20),
PurseBalance numeric
)
Create Table TTable----
(
Card_Number varchar(20),
Points varchar(20),
Chances int
)
insert into TTemp select * from
OPENROWSET('MICROSOFT.JET.OLEDB.4.0','Excel 5.0;HDR=YES;DATABASE=d:/test.xls','@tableName') as a
create trigger UpdateTable
on TTemp for insert
as
declare @cardNumber varchar(50),@purseDescription varchar(50),@purseBalbance varchar(50)
select @cardNumber=Card_Number,@purseDescription=PurseDescription, @purseBalbance=PurseBalance from updated
if(@purseDescription='GRAND DRAW CHANCES')
begin
update TTable set Points=@purseBalbance where Card_Number=@cardNumber
end
if(@purseDescription='CHANGI REWARDS POINTS')
begin
update TTable set Chances=1 where Card_Number=@cardNumber
end