Loading data incrementally from Synapse serverless pool External table to Azure SQL by using microsoft standard template pipeline but 'MergeData' script is failing with the error code "2011" and message is "Argument {0} is null or empty.\r\nParameter name
![User's image](https://learn-attachment.microsoft.com/api/attachments/4a858d01-4841-4eb0-9677-f7d9766e7f9a?platform=QnA)
In Merge Data Activity i have used the following code and it's Successfully executing in Azure Sql . but in pipeline it's failing with following error.
![User's image](https://learn-attachment.microsoft.com/api/attachments/a58eb766-2192-433b-ad98-15fe74b54c76?platform=QnA)
SQL CODE
Declare @TargetTable nvarchar(200) = '@{item().TABLE_NAME}';
Declare @CDCTable nvarchar(200) ='@{item().CDC_TABLE_NAME}'
declare @UpdateColumns nvarchar(max);
declare @Columns nvarchar(max);
Select @UpdateColumns = COALESCE(@UpdateColumns + ', ', '') + 'T.' + x.COLUMN_NAME + ' = S.' + x.COLUMN_NAME,
@Columns = COALESCE(@Columns + ', ', '') + x.COLUMN_NAME
from INFORMATION_SCHEMA.COLUMNS x
WHERE TABLE_NAME = replace(@TargetTable,'dbo.','')
and TABLE_SCHEMA = 'dbo'
select @UpdateColumns As UpdateColumns , @Columns As Columns
Declare @MergeStatement nvarchar(max);
set @MergeStatement
= ' MERGE ' + @TargetTable + ' T USING '+ @CDCTable + ' S' +
' ON T.RECID = S.RECID' +
' WHEN MATCHED and S.DML_Action = ''AFTER_UPDATE''' +
' THEN UPDATE SET ' +
@UpdateColumns +
' WHEN NOT MATCHED BY TARGET and S.DML_Action <> ''DELETE'' THEN INSERT (' +
@Columns +
') Values (' +
@Columns +
')' +
' WHEN MATCHED and S.DML_Action = ''DELETE''' +
' THEN DELETE;';
Execute sp_executesql @MergeStatement;
update SynapseToSQLTables set Status = 1, LastProcessedFile = '@{item().LAST_UPDATED_CDC_FILE}'
where TableName = @TargetTable;
-- drop table at the end
drop table @CDCTable
![User's image](https://learn-attachment.microsoft.com/api/attachments/8f346585-ab50-447a-a453-1412eb7b9ce9?platform=QnA)
Incremental Pipeline is reference taken from the following link https://github.com/microsoft/Dynamics-365-FastTrack-Implementation-Assets/blob/master/Analytics/SynapseToSQL_ADF/readme.md