The following code on Azure Synapse Serverless SQL Pool gives the following error:
Incorrect syntax near 'DISTRIBUTION'.
SELECT CM.EntityName,
--Before the first column of each table, construct a DROP TABLE statement if already exist
CASE WHEN CM.OrdinalPosition = 1
THEN
'DROP EXTERNAL TABLE MyTable' + '.' +
QUOTENAME(@EnrichedViewSchema) + '.' + CM.EntityName + '
CREATE TABLE MyTable' + '.' +
QUOTENAME(@EnrichedViewSchema) + '.' + CM.EntityName + '
WITH
(
DISTRIBUTION = ROUND_ROBIN
);
AS
SELECT DISTINCT '
ELSE ' ,'
END
Can someone look at the code and let me know where I might going wrong?
Azure Synapse SQL Server Pool Error: Incorrect syntax near 'DISTRIBUTION'
CREATE TABLE MyTable' + '.' +
QUOTENAME(@EnrichedViewSchema) + '.' +
CM.EntityName + '
WITH
(
DISTRIBUTION = ROUND_ROBIN
)
Reference: screenshot from Microsoft document Design tables using Synapse SQL - Azure Synapse Analytics | Microsoft Learn
there is an additional semicolon before AS in your script.
Wrong: CREATE TABLE XXX WITH(DISTRIBUTION=ROUND_ROBIN); AS SELECT
Correct: CREATE TABLE XXX WITH(DISTRIBUTION=ROUND_ROBIN) AS SELECT
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.