How to fetch number from the NVARCHAR value depending on the condition in Azure data Factory derived column?

Aravind 20 Reputation points
2023-12-14T11:07:30.6033333+00:00

Hi EveryOne,

We are migrating data from azure sql server to azure postgresql. so we have a requirement like in sql server one table have metadata column datatype: nvarchar

Example data: { "Type": 5, "TypeId": 50328 }

so there is type:5 then typeid value need to fetch in derived column so i will map this to postgresql int column in sink mapping but Need an expression in derived column. I tried few things but not working. like

IIF(BYPOSITION('"Type": 5' IN metadata) > 0,
    TOINTEGER(SUBSTRING(metadata, BYPOSITION('"TypeId":' IN metadata) + 10, BYPOSITION(',' IN SUBSTRING(metadata, BYPOSITION('"TypeId":' IN metadata) + 10)) - 1)),
    NULL())

no functions working for this in the derived column so please give the correct expression for this requirement in derived column in ADF.

Thanks & Regards

Aravind

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.
Azure Databricks
Azure Databricks
An Apache Spark-based analytics platform optimized for Azure.
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
{count} votes

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.