The following example demonstrates how to use column aliases in Snowflake. The first two columns, from the SQL Server code, are expected to be transformed from an assignment form into a normalized form using the AS keyword. The third and fourth columns are using valid Snowflake formats.
SQL Server
Snowflake
SELECT TOP
The basic case of SQL Server Select Top is supported by Snowflake. However, three more cases exist that are not supported, you can check them in the Known Issues section.
SQL Server
Snowflake
SELECT INTO
The following example shows the SELECT INTO is transformed into a CREATE TABLE AS, this is because in Snowflake there is no equivalent for SELECT INTO and to create a table based on a query has to be with the CREATE TABLE AS.
SQL Server
Snowflake
Another case is when including set operators such as EXCEPT and INTERSECT. The transformation is basically the same as the previous one.
SQL Server
Snowflake
Known Issues
SELECT TOP Aditional Arguments
Since PERCENT and WITH TIESkeywords affect the result, and they are not supported by Snowflake, they will be commented out and added as an error.
SQL Server
Snowflake
SELECT FOR
Since the FOR clause is not supported in Snowflake, it is commented out and added as an error during the transformation.
SQL Server
Snowflake
SELECT OPTION
The OPTION clause is not supported by Snowflake. It will be commented out and added as a warning during the transformation.
Notice that the OPTION statement has been removed from transformation because it is not relevant or not needed in Snowflake.
SQL Server
Snowflake
SELECT WITH
The WITH clause is not supported by Snowflake. It will be commented out and added as a warning during the transformation.
Notice that the WITH(NOLOCK, NOWAIT) statement has been removed from transformation because it is not relevant or not needed in Snowflake.
SELECT
MyCol1Alias = COL1,
MyCol2Alias = COL2,
COL3 AS MyCol3Alias,
COL4 MyCol4Alias
FROM TABLE1;
OUT -> SqlServer_01.sql
SELECT
COL1 AS MyCol1Alias,
COL2 AS MyCol2Alias,
COL3 AS MyCol3Alias,
COL4 MyCol4Alias
FROM
TABLE1;
IN -> SqlServer_02.sql
SELECT TOP 1 * from ATable;
OUT -> SqlServer_02.sql
SELECT TOP 1
*
from
ATable;
IN -> SqlServer_03.sql
SELECT * INTO NEWTABLE FROM TABLE1;
OUT -> SqlServer_03.sql
CREATE OR REPLACE TABLE NEWTABLE AS
SELECT
*
FROM
TABLE1;
IN -> SqlServer_04.sql
SELECT * INTO NEWTABLE FROM TABLE1
EXCEPT
SELECT * FROM TABLE2
INTERSECT
SELECT * FROM TABLE3;
OUT -> SqlServer_04.sql
CREATE OR REPLACE TABLE NEWTABLE AS
SELECT
*
FROM
TABLE1
EXCEPT
SELECT
*
FROM
TABLE2
INTERSECT
SELECT
*
FROM
TABLE3;
IN -> SqlServer_05.sql
SELECT TOP 1 PERCENT * from ATable;
SELECT TOP 1 WITH TIES * from ATable;
SELECT TOP 1 PERCENT WITH TIES * from ATable;
OUT -> SqlServer_05.sql
SELECT
TOP 1 !!!RESOLVE EWI!!! /*** SSC-EWI-0040 - THE STATEMENT IS NOT SUPPORTED IN SNOWFLAKE ***/!!!
*
from
ATable;
SELECT
TOP 1 !!!RESOLVE EWI!!! /*** SSC-EWI-0040 - THE STATEMENT IS NOT SUPPORTED IN SNOWFLAKE ***/!!!
*
from
ATable;
SELECT
TOP 1 !!!RESOLVE EWI!!! /*** SSC-EWI-0040 - THE STATEMENT IS NOT SUPPORTED IN SNOWFLAKE ***/!!!
*
from
ATable;
IN -> SqlServer_06.sql
SELECT column1, column2 FROM my_table FOR XML PATH('');
OUT -> SqlServer_06.sql
SELECT
column1,
column2
FROM
my_table
!!!RESOLVE EWI!!! /*** SSC-EWI-TS0044 - FOR XML CLAUSE IS NOT SUPPORTED IN SNOWFLAKE ***/!!!
FOR XML PATH('');
IN -> SqlServer_07.sql
SELECT column1, column2 FROM my_table OPTION (HASH GROUP, FAST 10);