Drops

DROP statements

DROP TABLE

Syntax in SQL Server

DROP TABLE [ IF EXISTS ] <table_name> [ ,...n ]  
[ ; ]  

Syntax in Snowflake

DROP TABLE [ IF EXISTS ] <name> [ CASCADE | RESTRICT ]

Translation

Translation for single DROP TABLE statements is very straightforward. As long as there is only one table being dropped within the statement, it's left as-is.

For example:

-- Input code
DROP TABLE IF EXISTS [table_name]
-- Output code
DROP TABLE IF EXISTS PUBLIC.table_name

The only noteworthy difference between SQL Server and Snowflake appears when the input statement drops more than one table. In these scenarios, a different DROP TABLE statement is created for each table being dropped.

For example:

-- Input code
DROP TABLE IF EXISTS [table_name], [table_name2], [table_name3]
-- Output code
DROP TABLE IF EXISTS PUBLIC.table_name;

DROP TABLE IF EXISTS PUBLIC.table_name2;

DROP TABLE IF EXISTS PUBLIC.table_name3;

Last updated