日期:2014-05-18  浏览次数:20355 次

帮忙进来看一下触发器
一个出发器
create trigger updateorderb2
on dbo.orderbl
for update
as
update dbo.orderxx set ifmoney=1 where orderID=(select top 1 orderrand from inserted)
update users set usermoney='convert((CONVERT(select usermoney from users where username=(select top 1 username from inserted))as decimal)
-CONVERT((select totleprice from orderbl where orderrand=(select top 1 orderrand from inserted)) as decimal) as nvarchar(50))' where username=(select top 1 username from inserted)


当更新orderbl中的inmoney=1的时候 同时更新 orderxx里所有外键=刚更新的主键值
然后同时把用户表中钱数减去相应的totleprice  
由于totleprice和usermoney都为nvarchar(50)所以我把他转换成decimal
但是当我运行程序时 出现将截断字符串或二进制数据 问题
前辈们解啊!


------解决方案--------------------
convert(nvarchar(CONVERT(decimal(select usermoney from users where username=(select top 1 username from inserted),2)) 
-CONVERT(decimal(select totleprice from orderbl where orderrand=(select top 1 orderrand from inserted),2)))
试试!
------解决方案--------------------
因为你的字符串转换成int值时出错了,或者超出了,int值的范围

所以建议表即然是int操作,那就用int字段,