简体   繁体   中英

How to create new table from Azure data factory in Azure SQL when copy succeeded or fail

I am doing copy activity in Azure data factory. I am copying csv file to azure sql db. I already setup all the things from linker service to data set. What I want is if copy activity succeeded or fail then I want to insert TableName, No. of rows copied and status (succeeded, fail) into Another table in Azure SQL. How can it be done.

You can use parameterized StoredProcedure Activity . You can then assign the values to parameter dynamically in pipeline.

Example:

Table to store copy details.

Create table [dbo].[CopyDetails](
TableName nvarchar(max),
NoOfRows int,
CopyStatus nvarchar(max)
)

Stored Procedure in same database as being copied

CREATE PROCEDURE recordDetails @TableName nvarchar(max), @NoOfRows int, @CopyStatus nvarchar(max)
AS
Insert into [dbo].[CopyDetails] 
VALUES
(@TableName, @NoOfRows, @CopyStatus)
GO

Create Variables accordingly in Pipeline

在此处输入图像描述

Sample working pipeline

在此处输入图像描述

在此处输入图像描述

Set variableRowsCopied

@string(activity('Copy data1').output.rowsCopied)

Set variableStatus

@activity('Copy data1').output.executionDetails[0].status

Set StoredProcedure Activity

Use variable to set dynamic values to Stored procedure parameters

在此处输入图像描述

After successfully executing

在此处输入图像描述

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM