October 21, 2024
Chicago 12, Melborne City, USA
SQL

Snowflake to_varchar adds space in front


Anyone can explain why to_varchar function in Snowflake adds space in front of output:

For example,

SELECT TO_VARCHAR(10101, '000000');
-- ouput: ' 010101'
SELECT LEN(TO_VARCHAR(10101, '000000'))
-- ouput: 7

I could wrap it with TRIM, but would like to understand behavior instead of adding unnecessary functions



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video