Groups | Blog | Home
all groups > sql server mseq > april 2004 >

sql server mseq : string formating of sql result


San Tuon
4/14/2004 5:27:15 PM
Hello.

I am performing a data conversion and an running into the
following problem.
I have a numeric column in table but wish to return
results as formated string via SQL. The results should be
as follows.

value 1.. want to return the string "01".
value 9.. want to return the string "09".
value 11.. want to return the string "11".

The table represents months in the year. so values are 0
to 11.

Any help would be much appreciated.
San Tuon
4/14/2004 5:41:49 PM
I just figure out how to do this.

If anyone is also interest there is an article at
http://www.databasejournal.com/features/mssql/print.php/10
894_2222111_1

but in brief the solution is

select cast(replace(str(job_lvl,3),' ','0')as char(3)) as
jl from employee

Regards San

AddThis Social Bookmark Button