Reputation: 1435
I am converting Access
query to SQL Server
.
I want to convert below lines to SQL
1. Format (210.6, "Standard")
2. Format (210.6, "#,##0.00")
How do i convert it to SQL query.
I have tried with below, but still not able to find the solution.
For the first query, i found below solution, which is correct
1. CONVERT(varchar, CAST(tSRO.OutputF11 AS money), 1)
Now, for second query, i do not know what i have to do.
Upvotes: 1
Views: 135
Reputation: 175636
From SQL Server 2012+ you can use FORMAT
:
SELECT FORMAT(210.6, '#,##0.00') -- 210.60
SELECT FORMAT(1210.6, '#,##0.00') -- 1,210.60
SQL Server before 2012:
SELECT REPLACE(CONVERT(VARCHAR,CONVERT(MONEY, 1210.6),1),'.00','') -- 1,210.60
Warning:
This operation is pure for presentation layer and should be done in application.
Upvotes: 2