declare @i integer set @i=1 select replace(str(@i,4,0),' ','0') select replace(str(vc_ID,4,0),' ','0') from SMS_Customer