日期:2014-05-17 浏览次数:20407 次
Create function F_Num(@Num numeric(18,4)) returns varchar(20) as begin declare @Str varchar(20) set @Str=RTRIM(@Num) set @Str=left(@Str,len(@Str)-PATINDEX('%[^0]%',REVERSE(@Str))+1) return(case when right(@Str,1)='.' then left(@Str,len(@Str)-1) else @Str end) end go declare @T table (ID numeric(18,4)) insert @T select 100 insert @T select 100.12 select dbo.F_Num(ID),ID from @T