找回密码
 注册账号

QQ登录

只需一步,快速开始

手机号码,快捷登录

手机号码,快捷登录

初学者课程:T3自学|T6自学|U8自学软件下载课件下载工具下载资料:通资料|U8资料|NC|培训|年结积分规则 | 使用常见问题Q&A
知识库:U8 | | NC | U9 | OA | 政务U8|U9|NCC|NC65|NC65客开|NCC客开新手必读 | 任务 | 快速增金币用友QQ群[微信群]
查看: 4750|回复: 10

[技巧] 字符串二进制截断错误排查

[复制链接]
发表于 2011-4-15 09:48:06 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册账号

×
--如下代码分享自用友时空牛人苹果 ,感谢苹果的奉献!


  1. declare @sql varchar(max),@aimtbname varchar(50),@sourcetbname varchar(50),@tbname varchar(50),@fdname varchar(50)
  2. set @sql = ''
  3. set @sourcetbname = 'tmp_dj_xsg212'
  4. set @aimtbname = 'jzorder_mx'
  5. set @tbname = ''
  6. set @fdname = ''
  7. --lixd 2011.4.2
  8. create table #t_aimstru(
  9.   fdname char(20),
  10.   fdtype char(50),
  11.   length int,
  12.   xprec int,
  13.   xscale int
  14. )
  15. create table #t_maxlen(
  16.   fdname char(20),
  17.   length int
  18. )
  19. delete from #t_aimstru
  20. insert into #t_aimstru
  21. select b.name as fdname,c.name as fdtype,b.length,b.xprec,b.xscale
  22. from sysobjects a
  23.      join syscolumns b on a.id = b.id
  24.      join systypes c on b.xtype=c.xtype and b.xusertype=c.xusertype
  25. where a.xtype='U' and a.name = @aimtbname
  26. declare cur_maxlen cursor for
  27. select b.name as fdname
  28. from sysobjects a join syscolumns b on a.id = b.id
  29.      join systypes c on b.xtype=c.xtype and b.xusertype=c.xusertype
  30. where a.xtype = 'U' and a.name = @sourcetbname and c.name in ('text','ntext','char','varchar','nchar','nvarchar')
  31. open cur_maxlen
  32. fetch next from cur_maxlen into @fdname
  33. delete from #t_maxlen
  34. while @@fetch_status =0
  35. begin
  36.   set @sql = 'select '''+@fdname+''' as fdname, max(datalength(rtrim(substring('+@fdname+',1,500))))  from '+@sourcetbname
  37.   insert into #t_maxlen exec(@sql)
  38.   fetch next from cur_maxlen into @fdname
  39. end
  40. close cur_maxlen
  41. deallocate cur_maxlen
  42. select a.fdname,a.length as sourcelength, b.length as aimlength
  43. from #t_maxlen a join #t_aimstru b on a.fdname = b.fdname
  44. where b.fdtype in ('char','varchar','nchar','nvarchar') and isnull(a.length,0)-isnull(b.length,0) > 0

  45. drop table #t_aimstru, #t_maxlen
复制代码
发表于 2011-5-4 22:40:36 | 显示全部楼层
这个必须学习!
发表于 2011-7-21 10:10:01 | 显示全部楼层
嗯,必要时候还是很好用的,强人
发表于 2011-12-16 01:56:52 | 显示全部楼层
这个需要顶一下!!一般都只能靠经验判断
回复 点赞 拍砖

使用道具 举报

发表于 2012-8-4 18:40:58 | 显示全部楼层
赚钱。。。。。。。。
回复 点赞 拍砖

使用道具 举报

发表于 2012-11-13 15:46:21 | 显示全部楼层
这个好
回复 点赞 拍砖

使用道具 举报

发表于 2012-11-13 16:02:52 | 显示全部楼层
阿斯顿发斯蒂芬随碟附送的
回复 点赞 拍砖

使用道具 举报

发表于 2012-11-13 16:15:01 | 显示全部楼层
阿斯顿发斯蒂芬
回复 点赞 拍砖

使用道具 举报

发表于 2012-11-14 20:30:01 | 显示全部楼层
有用的               
回复 点赞 拍砖

使用道具 举报

发表于 2012-11-14 20:30:34 | 显示全部楼层
多出这种强贴
回复 点赞 拍砖

使用道具 举报

发表于 2013-11-23 21:24:50 | 显示全部楼层
正在测试学习。。。
回复 点赞 拍砖

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号

本版积分规则

QQ|站长微信|Archiver|手机版|小黑屋|用友之家 ( 蜀ICP备07505338号|51072502110008 )

GMT+8, 2024-4-28 07:04 , Processed in 0.049328 second(s), 7 queries , Gzip On, Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表