Reputation: 53
There are backslashes in our Snowflake database and I want to replace them with blanks but the replace function is not working. Is there a way to remove backslashes from a string in Snowflake?
Upvotes: 0
Views: 3761
Reputation: 11086
Are you escaping the backslashes? The escape character for Snowflake string literals is a backslash, so if you want to replace a single backslash you have to put in two backslashes:
set my_string = 'My string with one \\ backslash'; --Shows how to escape a backslash
select $my_string; --Shows the effect of escaping a backslash, only one shows
select replace($my_string, '\\'); --Remove backslashes, replace with nothing
Upvotes: 1