简体   繁体   中英

Azure Data Factory - SQL

I would like to ask you if is it possible to use "output inserted" SQL statement in data flow (Azure Data Factory)

Currently, I am getting an error:

at Source 'source1': shaded.msdataflow.com.microsoft.sqlserver.jdbc.SQLServerException: A nested INSERT, UPDATE, DELETE, or MERGE statement is not allowed in a SELECT statement that is not the immediate source of rows for an INSERT statement.

Using this statement: 在此处输入图片说明

What I did:

I also checked stored procedures but they do not provide any output.

What I want:

I would like to get the 'Id' of row of inserted elements (Insert+Select in one operation).

As error shows, insert statement isn't allowed.

As a work around, you can do like this.

  1. create a Lookup activity and enter your SQL like this:

在此处输入图片说明

  1. create a data flow and create a parameter inside it. expression: @activity('Lookup1').output.firstRow.ID

在此处输入图片说明

3.Inside data flow, choose your table as your source and enter this expression:

concat('select ID from dbo.test6 where ID =',toString($ID))

4.If your need to do some transform, you can create a DerivedColumn and do like this:

在此处输入图片说明

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