In the sql query I have a total order value multiplied by 1000:
Total value: 195.41 Value Viewed: 195410.00
How can I remove the tab?
SELECT CAST (CONVERT (varchar, CAST (AS money 195410.00, 0) AS varchar)
In the sql query I have a total order value multiplied by 1000:
Total value: 195.41 Value Viewed: 195410.00
How can I remove the tab?
SELECT CAST (CONVERT (varchar, CAST (AS money 195410.00, 0) AS varchar)
As commented by @bigown, you just multiply the value by 100 instead of 1000.
If you do not have management over this multiplication, the conversion to INT suggested by @PabloVargas is also valid, as long as the value does not exceed that allowed by the field (-2 ^ 31 (-2,147,483,648) to 2 ^ 31 -1 (2,147,483,647) - link )
Conversion to INT:
SELECT CAST(195410.00 AS INT)
You can also simply suppress the characters after the dot:
select LEFT(195410.00, CHARINDEX('.', 195410.00) - 1)
You can make convert
to int
, see how it works
declare @valor_total decimal(18,2) = 195.41
select convert(int, @valor_total*1000)