Add leading zeros to integers less than 7 digits and ignore anything 7+
Ugly (and won't perform all that great), but

SELECT 
CASE WHEN len(Column) &gt; 7 THEN CAST(Column AS nvarchar(20))
ELSE RIGHT(rtrim('0000000' + CAST(column as nvarchar(20)), 7) END
FROM table