As you can see, TEMPORARY was added to the definition of the table, and the character # was replaced with T_.
Also, all references of the table will be transformed too, to match the new name given to the temporary table.
NULL and NOT NULL Column Option
NULL and NOT NULL column options are supported in Snowflake.
Source
IN -> SqlServer_03.sql
CREATETABLE [SCHEMA1].[TABLE1]( [COL1] [varchar](20) NOT NULL) ON [PRIMARY]GOCREATETABLE [SCHEMA1].[TABLE2]( [COL1] [varchar](20) NULL) ON [PRIMARY]GO
Expected
OUT -> SqlServer_03.sql
CREATE OR REPLACETABLESCHEMA1.TABLE1 ( COL1 VARCHAR(20) NOT NULL)COMMENT = '{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},"attributes":{"component":"transact"}}'
;CREATE OR REPLACETABLESCHEMA1.TABLE2 ( COL1 VARCHAR(20) NULL)COMMENT = '{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},"attributes":{"component":"transact"}}'
;
Identity Column Option
For identity columns, a sequence is created and assigned to the column.
Source
IN -> SqlServer_04.sql
CREATETABLEacct3.UnidentifiedCash3 (UnidentifiedCash_ID3 INTIDENTITY (666, 313) NOT NULL);
Expected
OUT -> SqlServer_04.sql
CREATE OR REPLACESEQUENCEacct3.UnidentifiedCash3_UnidentifiedCash_ID3STARTWITH666INCREMENT BY313COMMENT ='FOR TABLE-COLUMN acct3.UnidentifiedCash3.UnidentifiedCash_ID3';CREATE OR REPLACETABLEacct3.UnidentifiedCash3 (UnidentifiedCash_ID3 INTDEFAULT acct3.UnidentifiedCash3_UnidentifiedCash_ID3.NEXTVAL NOT NULL)COMMENT = '{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},"attributes":{"component":"transact"}}'
;
For more information, you can also check this warning related to this transformation.
Default Column Option
The default Expr is supported in Snowflake, however, in SqlServer it can come together with a constraint Name. Since that part is not supported in Snowflake, it is removed and a warning is added.
CREATE OR REPLACETABLESCHEMA1.TABLE1 ( COL1 VARCHAR(10)--** SSC-FDM-0012 - CONSTRAINT IN DEFAULT EXPRESSION IS NOT SUPPORTED IN SNOWFLAKE **DEFAULT ('0') NOT NULL)COMMENT = '{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},"attributes":{"component":"transact"}}'
;
Column Constraint
Source
IN -> SqlServer_06.sql
CREATETABLE [SalesLT].[Address]( [AddressID] [int] IDENTITY(1,1) NOTFOR REPLICATION NOT NULL, [AddressLine1] [nvarchar](60) NOT NULL, [AddressLine2] [nvarchar](60) NULL, [City] [nvarchar](30) NOT NULL, [StateProvince] [dbo].[Name] NOT NULL, [CountryRegion] [dbo].[Name] NOT NULL, [PostalCode] [nvarchar](15) NOT NULL, [rowguid] [uniqueidentifier] ROWGUIDCOLNOT NULL, [ModifiedDate] [datetime] NOT NULL,CONSTRAINT [PK_Address_AddressID] PRIMARY KEYCLUSTERED ( [AddressID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY],
CONSTRAINT [AK_Address_rowguid] UNIQUENONCLUSTERED ( [rowguid] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
Expected
OUT -> SqlServer_06.sql
CREATE OR REPLACESEQUENCESalesLT.Address_AddressIDSTARTWITH1 INCREMENT BY1COMMENT ='FOR TABLE-COLUMN SalesLT.Address.AddressID';--** SSC-FDM-0007 - MISSING DEPENDENT OBJECT "[dbo].[Name]" **CREATE OR REPLACETABLESalesLT.Address ( AddressID INTDEFAULT SalesLT.Address_AddressID.NEXTVAL NOT NULL, AddressLine1 VARCHAR(60) NOT NULL, AddressLine2 VARCHAR(60) NULL, City VARCHAR(30) NOT NULL, StateProvince VARIANT /*** SSC-FDM-TS0015 - DATA TYPE DBO.NAME IS NOT SUPPORTED IN SNOWFLAKE ***/NOT NULL, CountryRegion VARIANT /*** SSC-FDM-TS0015 - DATA TYPE DBO.NAME IS NOT SUPPORTED IN SNOWFLAKE ***/NOT NULL, PostalCode VARCHAR(15) NOT NULL, rowguid VARCHAR !!!RESOLVE EWI!!! /*** SSC-EWI-0040 - THE STATEMENT IS NOT SUPPORTED IN SNOWFLAKE ***/!!!ROWGUIDCOLNOT NULL, ModifiedDate TIMESTAMP_NTZ(3) NOT NULL,CONSTRAINT PK_Address_AddressID PRIMARY KEY (AddressID),CONSTRAINT AK_Address_rowguid UNIQUE (rowguid))COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": { "major": 0, "minor": 0, "patch": "0" }, "attributes": { "component": "transact", "convertedOn": "09/23/2024" }}'
;
Collate Column Option
For the transformation of Collate, please check the following link.
CREATE OR REPLACETABLESCHEMA1.TABLE1 ( COL1 VARCHAR(60)-- --** SSC-FDM-TS0009 - ENCRYPTED WITH NOT SUPPORTED IN SNOWFLAKE **-- ENCRYPTED WITH (COLUMN_ENCRYPTION_KEY = MyCEK, ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256')
)COMMENT = '{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},"attributes":{"component":"transact"}}'
;
NOT FOR REPLICATION
The NOT FOR REPLICATION option is not supported in Snowflake. It is used for the identity that is being migrated to a SEQUENCE.
Notice that NOT FOR REPLICATION is a statement that is not required in Snowflake because it is translated to an equivalent, so it is removed.
Source
IN -> SqlServer_08.sql
CREATETABLE [TABLE1] ( [COL1] INTIDENTITY (1, 1) NOTFOR REPLICATION NOT NULL) ON [PRIMARY];
Output
OUT -> SqlServer_08.sql
CREATE OR REPLACESEQUENCETABLE1_COL1STARTWITH1 INCREMENT BY1COMMENT ='FOR TABLE-COLUMN TABLE1.COL1';CREATE OR REPLACETABLETABLE1 ( COL1 INTDEFAULT TABLE1_COL1.NEXTVAL NOT NULL)COMMENT = '{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},"attributes":{"component":"transact"}}'
;
On Primary
The ON PRIMARY option is a statement that is used in SQL Server to define on which file an object, e.g. a table, is going to be created. Such as on a primary or secondary file group inside the database. Snowflake provides a different logic and indicates distinct constraints. Please review the following Snowflake documentation for more information.
Source
IN -> SqlServer_09.sql
CREATETABLE [TABLE1]([COL1] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULLCONSTRAINT [pk_dimAddress_AddressId] PRIMARY KEYCLUSTERED ([COL1]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
Output
OUT -> SqlServer_09.sql
CREATE OR REPLACETABLETABLE1 ( COL1 VARCHAR(255) COLLATE 'EN-CI-AS' /*** SSC-PRF-0002 - CASE INSENSITIVE COLUMNS CAN DECREASE THE PERFORMANCE OF QUERIES ***/ /*** SSC-FDM-TS0002 - COLLATION FOR VALUE CP1 NOT SUPPORTED ***/ NOT NULL
CONSTRAINT pk_dimAddress_AddressId PRIMARY KEY (COL1) ) COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": { "major": 0, "minor": 0, "patch": "0" }, "attributes": { "component": "transact", "convertedOn": "09/23/2024" }}'
;
ASC/DESC Column Sorting
The column sorting is not supported in Snowflake, the ASC or DESC keywords are being removed.
Source
IN -> SqlServer_10.sql
CREATETABLE [TABLE1]( [COL1] [int] NOT NULL,CONSTRAINT [constraint1] PRIMARY KEYCLUSTERED ([COL1] ASC)) ON [PRIMARY]
Computed columns are supported in Snowflake, we just need to add the explicit data type in order to be able to deploy the table, for example.
Source
IN -> SqlServer_11.sql
CREATETABLE [TABLE1]( [COL2] [int] NOT NULL, [COL2] [int] NOT NULL, [COL1] AS (COL3 * COL2),)
Output
OUT -> SqlServer_11.sql
CREATE OR REPLACETABLETABLE1 ( COL2 INTNOT NULL, COL2 INTNOT NULL, COL1 VARIANT AS (COL3 * COL2) /*** SSC-FDM-TS0014 - COMPUTED COLUMN WAS TRANSFORMED TO ITS SNOWFLAKE EQUIVALENT, FUNCTIONAL EQUIVALENCE VERIFICATION PENDING. ***/
)COMMENT = '{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},"attributes":{"component":"transact"}}'
;
If the computed expression cannot transformed, a warning is added, and a simple column definition with the expression return type will be used instead, like in the following example:
Source
IN -> SqlServer_12.sql
CREATETABLE [TABLE1]( [Col1] AS (CONVERT ([XML], ExpressionValue)))
The expression CONVERT ([NUMERIC], ExpressionValue) is not supported yet by SnowConvert, so, after it is inspected, SnowConvert will determine that its type is XML, so the transformation will be
OUT -> SqlServer_12.sql
CREATE OR REPLACETABLETABLE1 ( Col1 TEXT AS (CAST(ExpressionValue AS VARIANT !!!RESOLVE EWI!!! /*** SSC-EWI-0036 - XML DATA TYPE CONVERTED TO VARIANT ***/!!!)) /*** SSC-FDM-TS0014 - COMPUTED COLUMN WAS TRANSFORMED TO ITS SNOWFLAKE EQUIVALENT, FUNCTIONAL EQUIVALENCE VERIFICATION PENDING. ***/
)COMMENT = '{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},"attributes":{"component":"transact"}}'
;
SnowConvert will run a process to determine the original expression type in SQLServer. However, the column will have the equivalent target type. In the previous example, the column type in SQLServer was XML, but the target type in Snowflake for storing an XML is TEXT. For more information about data type mapping check the data types sections.
MASKED WITH Column Option
In SQL Server the data masking is used to keep sensitive information from nonprivileged users. Review the SQL SERVER documentation for more information. In Snowflake, there is a dynamic data masking functionality but it is available to Enterprise Edition only. Please, review the following Snowflake documentation.
CREATE OR REPLACETABLETABLE1( COL1 VARCHAR(50) !!!RESOLVE EWI!!! /*** SSC-EWI-TS0017 - COLUMN MASKING NOT SUPPORTED IN CREATE TABLE ***/!!!MASKEDWITH (FUNCTION='default()') NULL)COMMENT = '{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},"attributes":{"component":"transact"}}'
;
ROWGUIDCOL Column Option
ROWGUIDCOL is no longer applicable in Snowflake. It is used in SQL Server for UNIQUEIDENTIFIER types that are currently translated to VARCHAR. For example:
Input
IN -> SqlServer_14.sql
CREATETABLETABLEROWID ( [ROWGUID] UNIQUEIDENTIFIERROWGUIDCOLNOT NULL) ON [PRIMARY];
Output
OUT -> SqlServer_14.sql
CREATE OR REPLACETABLETABLEROWID ( ROWGUID VARCHAR !!!RESOLVE EWI!!! /*** SSC-EWI-0040 - THE STATEMENT IS NOT SUPPORTED IN SNOWFLAKE ***/!!!ROWGUIDCOLNOT NULL)COMMENT = '{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},"attributes":{"component":"transact"}}'
;
GENERATED ALWAYS AS ROW START/END Column Option
ROW START/END is not supported in Snowflake. An error is added when SnowConvert try to transform this kind of column option.
Input
IN -> SqlServer_15.sql
CREATETABLETABLEROWID ( [COL1] DATETIMEGENERATEDALWAYSASROWSTARTNOT NULL) ON [PRIMARY];
Output
OUT -> SqlServer_15.sql
CREATE OR REPLACETABLETABLEROWID ( COL1 TIMESTAMP_NTZ(3) GENERATED ALWAYS AS ROW START !!!RESOLVE EWI!!! /*** SSC-EWI-0073 - PENDING FUNCTIONAL EQUIVALENCE REVIEW FOR 'GeneratedClause' NODE ***/!!! NOT NULL
)COMMENT = '{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},"attributes":{"component":"transact"}}'
;
Known Issues
No issues were found.
Related EWIs
SSC-EWI-0036: Data type converted to another data type.