Synapse pipeline lookup activity - Select statement with where condition which compares string with '-'

Heta Desai 357 Reputation points
2022-06-08T16:16:14.18+00:00

In synapse pipeline I am using look up activity which reads data from Azure SQL Database. SELECT statement has WHERE condition which compares PipelineRunId.

PipelineRunId Example: a3de6326-8af4-43e9-a90e-d2e123f7e6fe

Below is the SELECT statement in the lookup activity:

SELECT COUNT(*) AS cnt FROM [dbo].[test] WHERE   
(Id= @{pipeline().parameters.Id} AND RunId=@{pipeline().parameters.ParentPipelineRunId})  

It throws below error.

{
"errorCode": "BadRequest",
"message": "Operation on target CheckObjectStatus failed: Failure happened on 'Source' side. ErrorCode=SqlOperationFailed,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=A database operation failed with the following error: 'Incorrect syntax near 'af4'.',Source=,''Type=System.Data.SqlClient.SqlException,Message=Incorrect syntax near 'af4'.,Source=.Net SqlClient Data Provider,SqlErrorNumber=102,Class=15,ErrorCode=-2146232060,State=1,Errors=[{Class=15,Number=102,State=1,Message=Incorrect syntax near 'af4'.,},],'",
"failureType": "UserError",
"target": "UpdateExeutionStatus",
"details": ""
}

If I remove RunId condition from WHERE clause SELECT statement in look up activity executes successfully.

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
0 comments No comments
{count} votes

Answer accepted by question author
  1. Nasreen Akter 10,891 Reputation points Volunteer Moderator
    2022-06-08T16:32:33.837+00:00

    Hi @Anonymous ,

    I think you are just missing '(Quotation Marks) around the IDs. Please try this:

    SELECT COUNT(*) AS cnt FROM [dbo].[test] WHERE
    (Id= '@{pipeline().parameters.Id}' AND RunId='@{pipeline().parameters.ParentPipelineRunId}')

    Thanks! :)

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

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