I am using the following to create a comma formatted number in T-SQL. How can I get rid of the decimal point and the digits after decimal. So if I get 1,112.00 after formatting, how would I get only 1,112?
SELECT CONVERT(varchar, CAST(1112 AS money), 1)
https://database.guide/how-to-format-numbers-in-sql-server/
Starting on SQL 2012 you can write:
SELECT FORMAT(ColumnName, 'N0');
PARSENAME(CONVERT(VARCHAR,CAST(1112 AS MONEY),1),2)
It will work nicely.
When convert number to money datatype automatically 2 zeros will be added after decimal. PARSENAME function will remove that zeros.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With