What is the data type for Currency in SQL Server?
DECLARE @Price Decimal(18,2) = 11.23
SELECT FORMAT(@Price,'c','en-US') AS 'CURRENCY IN US Culture'
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.
I think the best way to store the currency is to use either NUMERIC or DECIMAL data types as these values participates in calculations. If we use NVARCHAR to allow the storage with symbol like ($), it will cost extra during calculations when use in WHERE clause. We can choose the precision and scale accordingly.