Link to home
Start Free TrialLog in
Avatar of kpwhitte
kpwhitte

asked on

Add leading 0's

how do I add a leading 0 to all records in a column of type char?

exisiting data format  = 171347, 171331, etc
required data format = 0171347, 0171331, etc.

thanks
ASKER CERTIFIED SOLUTION
Avatar of SQL_SERVER_DBA
SQL_SERVER_DBA
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It also might be good to mention that if the field is a numeric datatype, you'd have to convert it to a character type or always select it back out adding the zero and converting it to a character:

SELECT '0' + convert(varchar, ColumnName) from tablename