
Applies to SQL Server 2019, 2022 and 2025.
Converting money in T-SQL comes up whenever amounts arrive as text, from a CSV, a spreadsheet export or a staging table where every column is varchar. The money data type is surprisingly forgiving about what it accepts, far more so than decimal, and that is both handy and a trap. Going the other way, from money back to text, has its own quirks with rounding and commas.
Converting money in T-SQL from a string
When you CAST or CONVERT a string to money, SQL Server lets you include a currency symbol in front of the number and thousands separators anywhere in it. Decimal won’t accept either. Here’s a staging table of the kind I see all the time:
CREATE TABLE #Staging
(
RowId int NOT NULL,
AmountTxt nvarchar(20) NOT NULL
);
INSERT #Staging (RowId, AmountTxt)
VALUES (1, N'£1,234.56'),
(2, N'$99.99'),
(3, N'-€15.00'),
(4, N'2500'),
(5, N'(40.00)');
SELECT RowId,
AmountTxt,
TRY_CAST(AmountTxt AS money) AS AsMoney,
TRY_CAST(AmountTxt AS decimal(12,2)) AS AsDecimal
FROM #Staging
ORDER BY RowId;
DROP TABLE #Staging;
Rows 1 to 4 all convert to money: the pound, dollar and euro signs are dropped and the comma is ignored. Only row 4 converts to decimal, because decimal wants a plain number. Row 5 fails for both, as money doesn’t understand the accounting style of showing a negative in brackets. I use TRY_CAST here so a bad row gives NULL instead of stopping the whole query, which makes it easy to find the rows that need a look.
Converting money back to a string
Money holds four decimal places, but a plain CAST to varchar only shows two, rounded. CONVERT gives you a choice through its style argument:
DECLARE @Amount money = 1234567.4567;
SELECT CAST(@Amount AS varchar(30)) AS PlainCast, -- 1234567.46
CONVERT(varchar(30), @Amount, 0) AS Style0, -- 1234567.46
CONVERT(varchar(30), @Amount, 1) AS Style1, -- 1,234,567.46
CONVERT(varchar(30), @Amount, 2) AS Style2; -- 1234567.4567
Style 0 is the default: two decimals, no separators. Style 1 adds commas every three digits, which is handy for a quick report. Style 2 keeps all four decimals, and it’s the one to use if the string is going to be converted back to money later, because it doesn’t lose anything. None of them add a currency symbol. If you need one, or a non-English layout, that’s a job for FORMAT, which I covered in the T-SQL FORMAT function.
The common mistake: trusting the comma
The mistake I see most is assuming money understands the number the way a person would. It doesn’t check where the commas are. It just throws them away. So '1,2,3,4.5' quietly becomes 1234.50, and anything with a stray comma converts without complaint.
That gets much worse with European-style figures, where the full stop separates thousands and the comma marks the decimals:
SELECT CAST('1.234,56' AS money) AS GermanStyle; -- 1.2346, not 1234.56
There’s no error. SQL Server reads the full stop as the decimal point, drops the comma and rounds to four places, so an invoice for over a thousand euros comes in at just over one. If you load files from anywhere that writes numbers like this, use TRY_PARSE with the culture instead:
SELECT TRY_PARSE('1.234,56' AS decimal(12,2) USING 'de-DE') AS GermanStyle; -- 1234.56
TRY_PARSE goes through the .NET CLR, so it’s slower than CAST and I wouldn’t run it over millions of rows if I didn’t have to. For a staging load where the source is known to be European, it’s the right tool. The real fix is to agree a format with whoever produces the file.
The second version of the same mistake is the round trip. CAST money to varchar and back again and you’ve lost the third and fourth decimals, because the plain CAST rounded to two. Use style 2 if the text will ever be read back.
Watch out for
- Brackets for negatives, like
(40.00), fail. Swap them for a leading minus with REPLACE before converting. - A minus sign works before or after the currency symbol:
'-$5.00'and'$-5.00'both give -5.00. - More than four decimals in the string are rounded, not truncated:
'12.34567'becomes 12.3457. - Leading and trailing spaces are ignored, but other junk such as a currency code (
'GBP 10') makes the conversion fail. - Money accepts a symbol but doesn’t record it. If a file mixes currencies, keep the currency in its own column before you convert, or you’ll add pounds to dollars.
- Don’t use CONVERT style 1 output as data. The commas make it text for display only.
Microsoft’s page on money and smallmoney (Transact-SQL) lists the currency symbols money accepts, and CAST and CONVERT (Transact-SQL) has the full table of money styles. There’s more on data loading and T-SQL habits in the SQL Server DBA Handbook.
This topic came up in the SQLServerCentral Question of the Day: Converting Money.
Clive Roberts DBA