我现在A表的字段里有01 02 10 11 12 100 101这些
我现在要把字段都变成3位 不足的补0
变成001 002 010.
怎么弄 谢谢
我现在要把字段都变成3位 不足的补0
变成001 002 010.
怎么弄 谢谢
解决方案 »
- 求大神帮忙解下sql的一个查询的题。。。
- SQL Server常见问题解答
- Sql Server2005中怎么创建标识列?
- 请高手帮解决sql嵌套查询 排序的问题
- 怎样取得一个表中所有的字段名称???
- error \Program Files\Microsoft SQL Server\90\Shared\sqlmgmproviderxpsp2up.mof
- 优化sql语句
- sql server 2008 数据库备份还原问题
- SQL SERVER2000 个人版和SQL SERVER2000 企业版区别
- sql中插入删除数据,因外键约束而失败,解决办法:
- 新手问题,sql2000如何添加计数列
- ***************请问怎么样查看一个数据表所占的页数以及索引页数.不连续的空间信息*************
go
create table # (col varchar(10))
insert # select '01' union all select '02'
union all select '10'
union all select '11'
union all select '12'
union all select '100'
union all select '101'
update # set col=right('000'+col,3)
select * from #
/*col
----------
001
002
010
011
012
100
101(影響 7 個資料列)*/
go
create table # (col varchar(10))
insert # select '01' union all select '02'
union all select '10'
union all select '11'
union all select '12'
union all select '100'
union all select '101'
select right('000'+col,3) from # --查詢
/*col
----------
001
002
010
011
012
100
101(影響 7 個資料列)*/
/*我现在A表的字段里有01 02 10 11 12 100 101这些
我现在要把字段都变成3位 不足的补0
变成001 002 010.
怎么弄 谢谢*/
declare @t table(col001 varchar(10))
insert @t select '01'
union all select '02'
union all select '10'
union all select '11'
union all select '12'
union all select '100'
union all select '101'select * from @tselect right('000'+col001,3) from @t/*
所影响的行数为 7 行)col001
----------
01
02
10
11
12
100
101(所影响的行数为 7 行)
------
001
002
010
011
012
100
101(所影响的行数为 7 行)
*/
set 列 = right('00' + 列,3)