Showing posts with label haveis. Show all posts
Showing posts with label haveis. Show all posts

Tuesday, March 20, 2012

Convert VARCHAR to money value

Ok i know this is simple but i just don't know the syntax. What I have
is a bunch of values and i want to be able to display them as money
values with a $ in front.
eg.
16000000
1000
160000
TO THIS
$16,000,000.00
$1000.00
$16,000.000
I'm using MS SQL 2000
Cheers
I guess it's not straight forward by just using convert function to change
datatype to money.
You need to write a function which will append $ and will separate thousands
with comma.
Woodies_46@.hotmail.com wrote:
>Ok i know this is simple but i just don't know the syntax. What I have
>is a bunch of values and i want to be able to display them as money
>values with a $ in front.
>eg.
>16000000
>1000
>160000
>TO THIS
>$16,000,000.00
>$1000.00
>$16,000.000
>I'm using MS SQL 2000
>Cheers
Message posted via droptable.com
http://www.droptable.com/Uwe/Forums...ivity/200603/1

Monday, March 19, 2012

Convert VARCHAR to money value

Ok i know this is simple but i just don't know the syntax. What I have
is a bunch of values and i want to be able to display them as money
values with a $ in front.
eg.
16000000
1000
160000
TO THIS
$16,000,000.00
$1000.00
$16,000.000
I'm using MS SQL 2000
CheersI guess it's not straight forward by just using convert function to change
datatype to money.
You need to write a function which will append $ and will separate thousands
with comma.
Woodies_46@.hotmail.com wrote:
>Ok i know this is simple but i just don't know the syntax. What I have
>is a bunch of values and i want to be able to display them as money
>values with a $ in front.
>eg.
>16000000
>1000
>160000
>TO THIS
>$16,000,000.00
>$1000.00
>$16,000.000
>I'm using MS SQL 2000
>Cheers
Message posted via droptable.com
http://www.droptable.com/Uwe/Forum...tivity/200603/1|||On 7 Mar 2006 20:32:18 -0800, Woodies_46@.hotmail.com wrote:

> Ok i know this is simple but i just don't know the syntax. What I have
> is a bunch of values and i want to be able to display them as money
> values with a $ in front.
> eg.
> 16000000
> 1000
> 160000
> TO THIS
> $16,000,000.00
> $1000.00
> $16,000.000
>
> I'm using MS SQL 2000
> Cheers
Ideally, this formatting would be done in your front-end application (or
reporting tool), rather than being formatted by SQL.

Convert VARCHAR into Money Value

Ok i know this is simple but i just don't know the syntax. What I have
is a bunch of values and i want to be able to display them as money
values with a $ in front.

eg.

16000000
1000
160000

TO THIS

$16,000,000.00
$1000.00
$16,000.000

I'm using MS SQL 2000

Cheers(Woodies_46@.hotmail.com) writes:
> Ok i know this is simple but i just don't know the syntax. What I have
> is a bunch of values and i want to be able to display them as money
> values with a $ in front.
> 16000000
> 1000
> 160000
> TO THIS
> $16,000,000.00
> $1000.00
> $16,000.000
>
> I'm using MS SQL 2000

Normally, formatting should be done client-side. Not the least because
the format is dependent on regional settings. The above is not how I
want my decimal commas and thousands separator.

Nevertheless, you can do this:

declare @.x money
select @.x = 9009090909
select '$' + convert(varchar, @.x, 1)

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx