sql 不够七位数 在左侧自动补零,怎么实现?
- 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 行受影响)
浙公网安备 33010602011771号