各位帮忙看下这个sql语句的问题
sql语句如下:
--开始事务
begin transaction
declare @errorsum int ,@usersid int,@sectionid int,@topiccounts int
select @sectionid=sid from bbssection where sname='.NET技术'
set @errorsum =@errorsum+@@error
select @usersid=uid from bbsusers where uname='sky'
print @usersid
set @errorsum =@errorsum+@@error
insert into bbstopic (tsid,tuid,ttopic,tcontents)
values (@sectionid,@usersid,'小弟请问.NET配置问题','.NET配置具体需要那些环境啊,我的页面怎么跑不起来呢?')
set @errorsum =@errorsum+@@error
update bbssection set stopiccount=stopiccount+1 where sid= @sectionid
set @errorsum =@errorsum+@@error
select * from bbssection where sname='.NET技术'
set @errorsum =@errorsum+@@error
set @topiccounts=@@rowcount
if @topiccounts=1
begin
update bbsusers set upoint=upoint+100 where uid=@usersid
end
else
begin
update bbsusers set upoint=upoint+50 where uid=@usersid
end
update bbsusers
set uclass=case
when upoint <500 then 1
when upoint between 500 and 1000 then 2
when upoint between 1001 and 2000 then 3
when upoint between 2001 and 4000 then 4
when upoint between 4001 and 5000 then 5
else 6
end
set @errorsum =@errorsum+@@error
print 'sky发布的帖子新是:'
select 板块=tsid,主题=ttopic,帖子内容=tcontents,发帖时间=ttime from bbstopic where tuid=@usersid
set @errorsum =@errorsum+@@error
if @errorsum <>0
begin
print '更新失败,回滚事务'
rollback transaction
end
else
begin
print'更新成功,提交事务,写入硬盘永久保存'
commit transaction
end
go
运行的结果如下:
5
消息 8152,级别 16,状态 14,第 9 行
将截断字符串或二进制数据。
语句已终止。
SID Sname SmasterID Sprofile SclickCount StopicCount
----------- -------------------------------- ----------- -------------------------------------------------- ----------- -----------
2 .NET技术 5 讨论web/xml、net remoting、duwaming 800 7
sky发布的帖子新是:
板块 主题 帖子内容 发帖时间
----------- -------------------- -------------------------------------------------- -----------------------
更新成功,提交事务,写入硬盘永久保存
问题是:
1,消息 8152,级别 16,状态 14,第 9 行
将截断字符串或二进制数据。是怎么回事?
2、这是事务处理过程,如果插入数据库失败,应该执行回滚操作,但是却执行的是提交事务的结果,那里错了?小弟求高手予以解答,谢谢