Skip to content

Snowflake Unable to insert multiple rows using insert into having md5 field

I am adding multiple rows using INSERT INTO table VALUES as follows:

And I am getting the following error:

SQL compilation error: syntax error line 2 at position 19 unexpected ‘as’. syntax error line 2 at position 28 unexpected ‘CURRENT_TIMESTAMP’. syntax error line 2 at position 50 unexpected ”DATA_SOURCE_1”. syntax error line 3 at position 19 unexpected ‘as’. syntax error line 3 at position 28 unexpected ‘CURRENT_TIMESTAMP’. syntax error line 3 at position 50 unexpected ”DATA_SOURCE_1”.

I tried to remove the as from the subqueries but I got the following error:

SQL compilation error: Invalid expression [MD5(MD5(‘test’))] in VALUES clause

I know that md5 should return a value not an expression that’s why I used AS but it didn’t work.

Advertisement

Answer

That seems like a bug to me and it’s kind of similar to this question. You can write the insert in a different way however to achieve the same result:

or alternatively like the following, which may be more concise if you have many rows in the VALUE part:

User contributions licensed under: CC BY-SA
9 People found this is helpful