Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the data type for Currency in SQL Server?

Tags:

sql-server

What is the data type to the currency value in SQL Server.

e.g: I want to store $11.23.

Can I use money type and addtionally will it store the $ symbol?

like image 825
smsh Avatar asked Sep 10 '15 08:09

smsh


2 Answers

DECLARE @Price Decimal(18,2) = 11.23
SELECT FORMAT(@Price,'c','en-US') AS 'CURRENCY IN US Culture'
like image 166
Alfaiz Ahmed Avatar answered Nov 15 '22 07:11

Alfaiz Ahmed


answering to the question in the title, the datatype for currency is MONEY.

the money datatype will store the information only, without the format: in your example the information is 11.23 so that's what is saved into the database.

the $ sign is part of the format so it will not be stored into the money field.

the usual solution is to have a MONEY field for the amount and a VARCHAR field for the currency symbol/name.

like image 28
Paolo Avatar answered Nov 15 '22 05:11

Paolo