Forum Discussion
How to use parameters in Lookup activity Query
- 7 months ago
Convert the SQL into a stred procedure and when using the Lookup, select stored procedure then you can import the parameters into the lookup activity and place the parameter in the expression builder.
Hi Mr_Coffee ,
Thanks for reaching out to the Microsoft fabric community forum.
The issue arises because pipeline parameters in Fabric Lookup activities are not automatically recognized as SQL string literals. When you write WHERE file_name = @{pipeline().parameters.file_name}, Fabric inserts the parameter value directly into the query without quotes.
For example, if your parameter is a string such as myFirstFile, the query becomes WHERE file_name = myFirstFile, which SQL interprets as a column or identifier, resulting in an error. To resolve this, enclose the parameter in single quotes within your query: WHERE file_name = '@{pipeline().parameters.file_name}'. This adjustment ensures that SQL processes the value as a string, allowing the query to execute as intended. Please note that the UI preview only shows parameter substitution; the actual query is executed during pipeline runtime. With this change, your Lookup activity should function correctly, enabling you to proceed with your metadata driven pipeline.
Best Regards,
Tejaswi.
Community Support