Y
yuanyoufa
Unregistered / Unconfirmed
GUEST, unregistred user!
DECLARE @JF DECIMAL(10,2),@SY decimal(10,2),@string char(10)
select @string=(select count(*) from jifensc where riqi<convert(char(10),dateadd(month,-6,getdate()),120)and kkhcode='0001')
if @string>0
begin
delete jifensc where riqi<convert(char(10),dateadd(month,-6,getdate()),120)and kkhcode='0001'
end
/*1.删除超过六个月的记录*/
insert into jifensc (kkhcode,riqi,jifen) values ('0001','2006-06-02',4)
/*2.增加记录*/
SELECT @JF=(select sum(jifen) from jifensc WHERE kkhcode='0001')
IF @JF>=10
BEGIN
select @sy=(@jf-10.00)
delete jifensc where kkhcode='0001'
insert into jifensc(kkhcode,riqi,jifen) values ('0001','2006-06-02',@sy)
END
/*3.修改并增加记录*/
我想在这个存储过程中加事务管理,如果有任何(1.2.3)有一个遇到问题时的话,数据都将回滚!都不执行!!!!
这个事务该怎么加??
select @string=(select count(*) from jifensc where riqi<convert(char(10),dateadd(month,-6,getdate()),120)and kkhcode='0001')
if @string>0
begin
delete jifensc where riqi<convert(char(10),dateadd(month,-6,getdate()),120)and kkhcode='0001'
end
/*1.删除超过六个月的记录*/
insert into jifensc (kkhcode,riqi,jifen) values ('0001','2006-06-02',4)
/*2.增加记录*/
SELECT @JF=(select sum(jifen) from jifensc WHERE kkhcode='0001')
IF @JF>=10
BEGIN
select @sy=(@jf-10.00)
delete jifensc where kkhcode='0001'
insert into jifensc(kkhcode,riqi,jifen) values ('0001','2006-06-02',@sy)
END
/*3.修改并增加记录*/
我想在这个存储过程中加事务管理,如果有任何(1.2.3)有一个遇到问题时的话,数据都将回滚!都不执行!!!!
这个事务该怎么加??