Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

What is the data type for Currency in SQL Server?

Writer Matthew Martinez

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?

4

4 Answers

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.

3

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.

it should be DECIMAL(,) OR NUMERIC in SQL. eg DECIMAL(20,2)

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy