服务热线:022-26677809 , 13821206318
坚守“用户之友”的初心,做“专业的奋斗者”,始终坚持“持续创新”
首页 > 知识库 > 正文

科目汇总打印

- 浏览:1629 - 发布时间:2008-07-06 13:11:11.0
问题版本: 812-U6普及版3.1 plus1 问题模块: 1-总账
所属行业: 0-通用 问题状态: 1-UU通注册用户
关 键 字: 科目汇总打印 适用产品: 809
补 丁 号: 开放状态: 0-UU通注册用户
原问题号: 提交时间: 2008-7-6 13:11:11
问题名称: 科目汇总打印
问题现象: 科目下级科目较多,有时需要汇总打印至上一级,有时需要汇总打印至一级科目,有时不汇总打印,在科目中改工作量极大!
原因分析: 现在还没有工具,你可以在数据库中分情况按照以下语句执行,操作前请备份好数据! --不汇总 update code set cgather=null --末级汇总到一级 declare @lenth as int set @lenth=(select left(codingrule,1) from gradedef where keyword='code') update code set cgather=left(ccode,@lenth) where igrade<>1 --末级汇总到上一级(中间级汇总到上一级等没有意义) declare @ccode as nvarchar(1000) declare @newccode as nvarchar(1000) declare @igrade as int declare @lenth as int DECLARE TST_CURSOR CURSOR FOR SELECT ccode,igrade FROM code where bend=1 and igrade>1 ORDER BY ccode OPEN TST_CURSOR FETCH NEXT FROM TST_CURSOR into @ccode,@igrade WHILE @@FETCH_STATUS = 0 BEGIN set @lenth=(select right(left(codingrule,@igrade),1) from gradedef where keyword='code') set @newccode=(select left(ccode,len(ccode)-@lenth) from code where ccode=@ccode) update code set cgather=@newccode where ccode=@ccode FETCH NEXT FROM TST_CURSOR into @ccode,@igrade END CLOSE TST_CURSOR DEALLOCATE TST_CURSOR
解决方案: 现在还没有工具,你可以在数据库中分情况按照以下语句执行,操作前请备份好数据! --不汇总 update code set cgather=null --末级汇总到一级 declare @lenth as int set @lenth=(select left(codingrule,1) from gradedef where keyword='code') update code set cgather=left(ccode,@lenth) where igrade<>1 --末级汇总到上一级(中间级汇总到上一级等没有意义) declare @ccode as nvarchar(1000) declare @newccode as nvarchar(1000) declare @igrade as int declare @lenth as int DECLARE TST_CURSOR CURSOR FOR SELECT ccode,igrade FROM code where bend=1 and igrade>1 ORDER BY ccode OPEN TST_CURSOR FETCH NEXT FROM TST_CURSOR into @ccode,@igrade WHILE @@FETCH_STATUS = 0 BEGIN set @lenth=(select right(left(codingrule,@igrade),1) from gradedef where keyword='code') set @newccode=(select left(ccode,len(ccode)-@lenth) from code where ccode=@ccode) update code set cgather=@newccode where ccode=@ccode FETCH NEXT FROM TST_CURSOR into @ccode,@igrade END CLOSE TST_CURSOR DEALLOCATE TST_CURSOR