原数据列:
编号
1
2
3
.
.
.
10
11
.
.
100
101
.
.
我想让该列变为五位,不满五位前面自动填0,能不能用简单的语句实现.
结果如下:编号
00001
00002
00003
.
.
.
00010
00011
.
.
00100
00111
.
.
.注:该列为varchar型先谢了.
编号
1
2
3
.
.
.
10
11
.
.
100
101
.
.
我想让该列变为五位,不满五位前面自动填0,能不能用简单的语句实现.
结果如下:编号
00001
00002
00003
.
.
.
00010
00011
.
.
00100
00111
.
.
.注:该列为varchar型先谢了.
insert into # select top 10 id from sysobjectsupdate # set num=right(100000+num,5) select * from #
insert @t
select '1' union all
select '2' union all
select '3' union all
select '4' union all
select '5'update @t set 编号 = right('0000' + rtrim(编号),5)select * from @t