Reputation: 59
I'm working on Migrating SQL Server data to Snowflake and trying to convert Int to Decimal. But the response is not what I'm expecting.
In SQL If you run this query Select 1.0000
or Select Cast(1 as Decimal(12,4))
the result will 1.000
.
If I do the same in Snowflake the result is 1. Is there a way to fix it?
Thanks
Upvotes: 1
Views: 3132
Reputation: 175706
Select Cast(1 as Decimal(12,4)) the result will 1.000. If I do the same in Snowflake the result is 1. Is there a way to fix it?
Representation of the number does not matter. It is most likely a client tool that shows it without decimal places.
When EXPLICIT cast is involved the data type is set as requested and it could be easily confirmed with DESCRIBE RESULT:
SELECT CAST(1 AS DECIMAL(12,4)) AS col;
DESCRIBE RESULT LAST_QUERY_ID();
-- name type kind null?
-- col NUMBER(12,4) COLUMN Y
DECIMAL and NUMBER are synonyms in Snowflake.
Upvotes: 1