I have a stored procedure in Synapse Dedicated pool which takes a parquet file from adls and creates a staging table in dedicated pool:
ALTER PROCEDURE dbo.Staging_Tables_sp
(
@TableName VARCHAR(MAX),
@SchemaName VARCHAR(MAX)
)
AS
BEGIN
EXEC ('SET ANSI_NULLS ON;
SET QUOTED_IDENTIFIER ON;
CREATE EXTERNAL TABLE [' + @SchemaName + '].[Staging_' + @TableName +']
WITH (
LOCATION = N''/Folder/ParquetFiles/' + @TableName + '/'',
DATA_SOURCE = [gold_parquet],
FILE_FORMAT = [ParquetFormat],
REJECT_TYPE = VALUE,
REJECT_VALUE = 0)');
END
Execute statement:
DECLARE @TableName varchar(max)
DECLARE @SchemaName varchar(max)
EXECUTE [dbo].[Staging_Tables_sp]
@TableName = 'Table',
@SchemaName = 'Schema'
When I try to execute it I get the following error:
Parse error at line: 10, column: 22: Incorrect syntax near ‘)’.
2
Answers
In T-SQL, to include a single quote character in a string, you need to escape it by doubling it, you did it at the beginning of the line, but it is missed at the end
So, you can modify this line
With this
I got your example working by adding a ‘select’ to query the parquet file using a view.
view: