您的位置:首页 > 数据库

sql 不够七位数 在左侧自动补零,怎么实现?

2010-08-27 08:05 218 查看
来自:http://topic.csdn.net/u/20100826/08/c6ab7727-85d8-4052-88da-dbd158b2d51f.html?62668

回答者:

ws_hgo

(蓝天白云--(全面提升!!))

等 级:


if object_id('[TB]') is not null drop table [TB]
create table [TB]([id] int)
insert [TB]
select 49999 union all
select 4565 union all
select 12362 union all
select 1111111 union all
select 232132 union all
select 2222
GO
select right('000000'+ltrim([id]),7) id from [TB]
id
--------------
0049999
0004565
0012362
1111111
0232132
0002222
(6 行受影响)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: