--视数据而定 select A+'-'+right('000'+cast(b as varchar(3)),3) from tb
select a+'-'+right(1000+b,3) from tb
SELECT A+'-'+REPLACE(STR(B,3,0),' ','0') FROM [表名]
select A+'-00'+B from tb
declare @table table(a varchar(5),b varchar(7)) insert into @table select 'X','1' union all select 'X','2' union all select 'X','111' select a+'-'++right('000'+b,3) from @table
select A+'-'+right('000'+cast(b as varchar(3)),3) from tb
select a+'-'+right(1000+b,3)
from tb
SELECT A+'-'+REPLACE(STR(B,3,0),' ','0') FROM [表名]
select A+'-00'+B from tb
declare @table table(a varchar(5),b varchar(7))
insert into @table
select 'X','1' union all
select 'X','2' union all
select 'X','111'
select a+'-'++right('000'+b,3) from @table