Is there any function in SQL Server to change the format of a numeric field(e.g. value 125000 to $1,25,000, 10000 to $10,000 etc ),just like TO_CHAR function in Oracle
Printable View
Is there any function in SQL Server to change the format of a numeric field(e.g. value 125000 to $1,25,000, 10000 to $10,000 etc ),just like TO_CHAR function in Oracle
Hi,
you can try to use the CAST(expression AS data_type) or CONVERT (data_type[(length)], expression [, style])
functions.
ex:
select CAST(EMPNO AS char(2)) from EMP;
select CONVERT(char(2), EMPNO) from EMP;
regards.
It's been a long time since SQLServer, but for some reason, I think that the conversion functions will only convert the datatype. I *think* you then want to use a function maybe called 'format' to actually format the string - not positive of this at all - just something to check into.
- Chris
the problem is still unsolved