sqlserver系统函数把int类型的1显示为char类型的001

to_char(1, ‘000 ‘)函数

1
select to_char(1, '000 ') from demo

1
select   right( '00 '+cast(CustomerID   as   varchar(3)),3)   from   ...

right((10000+字段名),3)就是3位的.

支持可以处理得简单些:

1
select   right( '00 '+cast(CustomerID   as   varchar(3)),3)   from   ...