a comma as a seperator.
ie
50000 would be $50,000
1234567 would be $1,234,567
etc.
I am just looking to do this via the SELECT statement.
Any suggestions would be helpful.
Use CONVERT function to do this.
Try something as:
SELECT '$'+ CONVERT(VARCHAR(50), money_column, 1) AS column_name
FROM <table>
Vishal Parkar
vgparkar@.yahoo.co.in | vgparkar@.hotmail.com
|||That works good to put the $ sign in. But is there also a
way to put the commas in?
>--Original Message--
>Use CONVERT function to do this.
>Try something as:
>SELECT '$'+ CONVERT(VARCHAR(50), money_column, 1) AS
column_name
>FROM <table>
>
>--
>Vishal Parkar
>vgparkar@.yahoo.co.in | vgparkar@.hotmail.com
>
>.
>
|||yes,
-- if column has datatype money then you can use query i've mentioned
earlier.
-- or else you will explicitly have to convert numeric value to money.
-- see 2nd query below.
create table t(money_column money)
insert into t values (123456)
SELECT '$' + CONVERT(VARCHAR(50), money_column, 1) AS column_name
FROM t
-- query if datatype is not meney
create table t(money_column int)
insert into t values (123456)
SELECT '$' + CONVERT(VARCHAR(50), cast(money_column as money), 1) AS
column_name
FROM t
Vishal Parkar
vgparkar@.yahoo.co.in | vgparkar@.hotmail.com
|||
Quote:
Use CONVERT function to do this.
Try something as:
SELECT '$'+ CONVERT(VARCHAR(50), money_column, 1) AS column_name
FROM <table>
Vishal Parkar
vgparkar@.yahoo.co.in | vgparkar@.hotmail.com
How do I get these 0's to drop? Here is the code
SELECT Product, [BU/ST], Pack, '$' + CONVERT(VARCHAR(50), UnitPrice * 1.40, 1) AS UnitPrice
FROM dbo.Regional
ORDER BY Flower
No comments:
Post a Comment