Quantcast
Channel: beyondrelational.com
Viewing all articles
Browse latest Browse all 25

Money datatype and formatted values

$
0
0


Money is one of the datatypes in SQL Server and it can be used to store monetary values. It will not only accept integer and decimal values but formatted values too. For example you can express values that include comma and currency symbol

Consider the following example

 

create table #temp
(
	money_value money
)


insert into #temp (money_value )
select '100' union all
select '567.33' union all
select '$8000' union all
select '-2600' union all
select '2012,10,19' union all
select '2,345,469.00' union all
select '5.00' union all
select ',' union all
select '.' 

select money_value from #temp

The result is
money_value
---------------------
100.00
567.33
8000.00
-2600.00
20121019.00
2345469.00
5.00
0.00
0.00

As you see the expressions for money values include comma within numbers, a single comma and curreny symbol $. All these expressions are correctly stored in ther money datatype column.

Characters like space, comma and a currency symbol without any numbers will be stored as zero.

Note : Other datatypes like decimal and float will not accept formatted values


Viewing all articles
Browse latest Browse all 25

Trending Articles