Azure Data factory copy activity failed mapping strings (from csv) to Azure SQL table sink uniqueidentifier field

杀马特。学长 韩版系。学妹 提交于 2019-12-02 07:15:23

I reproduce your issue on my side.

The reason is data types of source and sink are dismatch.You could check the Data type mapping for SQL server.

Your source data type is string which is mapped to nvarchar or varchar, and uniqueidentifier in sql database needs GUID type in azure data factory.

So,please configure sql server stored procedure in your sql server sink as a workaround.

Please follow the steps from this doc:

Step 1: Configure your Sink dataset:

Step 2: Configure Sink section in copy activity as follows:

Step 3: In your database, define the table type with the same name as sqlWriterTableType. Notice that the schema of the table type should be same as the schema returned by your input data.

    CREATE TYPE [dbo].[CsvType] AS TABLE(
    [ID] [varchar](256) NOT NULL
)

Step 4: In your database, define the stored procedure with the same name as SqlWriterStoredProcedureName. It handles input data from your specified source, and merge into the output table. Notice that the parameter name of the stored procedure should be the same as the "tableName" defined in dataset.

Create PROCEDURE convertCsv @ctest [dbo].[CsvType] READONLY
AS
BEGIN
  MERGE [dbo].[adf] AS target
  USING @ctest AS source
  ON (1=1)
  WHEN NOT MATCHED THEN
      INSERT (id)
      VALUES (convert(uniqueidentifier,source.ID));
END

Output:

Hope it helps you.Any concern,please free feel to let me know.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!