简体   繁体   English

Azure 数据工厂 - SQL

[英]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)我想问你是否可以在数据流中使用“输出插入”SQL语句(Azure数据工厂)

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.在源“source1”处:shaded.msdataflow.com.microsoft.sqlserver.jdbc.SQLServerException:SELECT 语句中不允许嵌套的 INSERT、UPDATE、DELETE 或 MERGE 语句,该语句不是 INSERT 语句的直接行源.

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).我想获得插入元素行的“Id”(在一个操作中插入+选择)。

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:创建一个查找活动并像这样输入您的 SQL:

在此处输入图片说明

  1. create a data flow and create a parameter inside it.创建一个数据流并在其中创建一个参数。 expression: @activity('Lookup1').output.firstRow.ID表达式: @activity('Lookup1').output.firstRow.ID

在此处输入图片说明

3.Inside data flow, choose your table as your source and enter this expression: 3.在数据流内部,选择您的表作为源并输入以下表达式:

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: 4.如果你需要做一些转换,你可以创建一个DerivedColumn并这样做:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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