Parameter value in table

Rohit Kulkarni 691 Reputation points
2023-04-05T15:41:28.7233333+00:00

Hello Team, I have hard coded values in one of the table User's image

And I am passing this column as a parameter and try to delete some values .The below is mentioned querie: DELETE FROM [S4].[@{pipeline().parameters.DESTINATION_TABLE_NAME}] WHERE ERDAT >='@{item().LastLoadDate}' OR @{pipeline().parameters.WHERE_SQL} >='@{item().LastLoadDate}' I am getting error : ErrorCode=SqlOperationFailed,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=A database operation failed with the following error: 'Incorrect syntax near '>'.',Source=,''Type=System.Data.SqlClient.SqlException,Message=Incorrect syntax near '>'.,Source=.Net SqlClient Data Provider,SqlErrorNumber=102,Class=15,ErrorCode=-2146232060,State=1,Errors=[{Class=15,Number=102,State=1,Message=Incorrect syntax near '>'.,},],' Please advise. Regards Rohit

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,014 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bhargava-MSFT 31,121 Reputation points Microsoft Employee
    2023-04-06T21:10:44.4066667+00:00

    Hello Rohit Kulkarni, Can you use the below dynamic SQL and see if it helps? DECLARE @sql NVARCHAR(MAX) SET @sql = N'DELETE FROM [S4].' + QUOTENAME('@{pipeline().parameters.DESTINATION_TABLE_NAME}') + ' WHERE ERDAT >= @LastLoadDate OR ' + '@{pipeline().parameters.WHERE_SQL}' EXEC sp_executesql @sql, N'@LastLoadDate datetime', @LastLoadDate = '@{item().LastLoadDate}'

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.