34,593
社区成员
发帖
与我相关
我的任务
分享
create table tb(id decimal(18,2))
insert into tb values(20000.00)
insert into tb values(154248.25)
go
select right('0000000000000000' + cast(cast(id*100 as int) as varchar),17) from tb
/*
----------------------------------
00000000002000000
00000000015424825
(所影响的行数为 2 行)
*/
select right('0000000000000000' + ltrim(cast(id*100 as int)),17) from tb
/*
----------------------------------
00000000002000000
00000000015424825
(所影响的行数为 2 行)
*/
drop table tb
select right('00000000000000000000000000'+ltrim(金额*100),17) from tb
select right(REPLICATE('0',17)+ltrim(金额*100),17) from tb --17是总位数.
select right('0000000000'+ltrim(金额*100),17) from tb --17是总位数.
--可以啊
declare @a numeric,@b numeric
set @a = 20000.00
set @b = 154248.25
print right('0000000000'+ltrim(@a*100),17)
print right('0000000000'+ltrim(@b*100),17)