sql 中去除多余的零

it2026-05-20  11

代码 declare   @bl   decimal ( 10 , 6 ),         @str   char ( 20 ), @T   char ( 20 ),         @str2   char ( 20 ), @str3   char ( 20 ), @zx1   int   set   @bl = 1110.3720000   set   @T = rtrim ( ltrim ( REVERSE ( @bl ))) set   @zx1 = cast ( @bl   as   int set   @str2 = cast ( @zx1   as   char ( 10 )) set   @zx1 = cast ( cast ( @T   as   decimal ( 10 , 6 ))  as   int set   @str3 = ltrim ( REVERSE ( cast ( @zx1   as   char ( 10 )))) if   @str3 = 0   set   @str = rtrim ( cast ( @str2   as   char ( 20 )))  else   set   @str = rtrim ( cast ( @str2   as   char ( 20 ))) + ' . ' + rtrim ( cast ( @str3   as   char ( 6 )))  print   @str  

转载于:https://www.cnblogs.com/lfzwenzhu/archive/2010/05/18/1738137.html

相关资源:SQLServer多种去除尾数多余的0
最新回复(0)