Reputation: 2503
I have variable called Query
in Azure Data Factory
.
I expect value like: Select CustomerName From Customer Where City = 'London'
However I occasionally get value like: 'Select CustomerName From Customer Where City = 'London''
I would like to remove single quote from beginning and end if value starts with ' Quote
should not be removed if value does not start with quote.
How to remove quote marks from variable?
Upvotes: 1
Views: 874
Reputation: 5074
Use the If()
function in the expression to evaluate if the variable value starts with a single quote (').
If the expression returns true then using substring exclude the first and last single quotes from the variable value. If false the value returns with no change.
Example:
Here, the variable (Query) value contains a single quote at the start and end of the value.
Using the Set variable
activity, store the result in a variable (Final_query) after removing quotes if it contains at the start of the value.
@if(equals(substring(variables('Query'),0,1),''''),substring(variables('Query'),1,sub(length(variables('Query')),2)),variables('Query'))
Output:
Removed single quotes from start and end of the value.
Upvotes: 2