AzureSynapse ForEach SQL INSERT giving ??? for foreign text

Viewed 42

I am a Data Scientist who has been given a Data Engineering task and I am seriously struglling. Please help! I am very new to AzureSynapse and am facing an issue with inserts into my MSSQL DB.

I have a Lookup activity which reads a .json file, followed by a ForEach command which adds some columns and then inserts the rows into my DB.

The issue I am facing is that the foreign text is showing on the DB as ?????. The columns are set as dtype NVARCHAR, which can accept foreign text strings and the output of both the Lookup and ForEach activities have the correct format.

Why is the text showing as ??? on the DB and how can I fix this issue? Maybe my insert statement is incorrect?

I have posted screenshots below. Many thanks for any support.

Pipeline: Pipeline

Lookup Output: Lookup Output

ForEach Output: ForEach Output

ForEach Activity: ForEach Activity

ForEach Script: ForEach Script

DB dtypes: enter image description here

DB Results: DB Results

1 Answers

The solution was hilariously simple. All I had to do was preprend an N before the Values where they were intended to be nvarchar. i.e. instead of '@{item().Jobtitle}' it should be N'@{item().Jobtitle}'.

Prepended the N to all NVARCHAR values and it shows in the DB with the foreign text.

Related