mysql - Pad Varchar with 0 in SQL Server 2005 -
i have tried following this , this need pad column zeros.
so have field
name_id 1 2 21 74
and want like
name_id 001 002 021 074
so have tried doing this:
select right('000'+ name_id,3) tblcoordinates;
but result is:
right('000'+name_id,3) 1 2 21 74
i using mysql server 2005. wrong select statement? thanks
you need convert name_id
varchar
first:
select right('000' + convert(varchar(3), name_id), 3) tblcoordinates;
if you're using mysql, there built-in function lpad()
select lpad(name_id, 3, '0') tblcoordinates;
Comments
Post a Comment