select RIGHT(REPLICATE('0',3)+CAST(3 AS varchar(10)),3) 003 select RIGHT(REPLICATE('0',3)+CAST(12 AS varchar(10)),3) 012 select RIGHT(REPLICATE('0',3)+CAST(123 AS varchar(10)),3) 123