简体   繁体   English

如何通过使用Azure Data Factory中的复制活动将常量值更新到sql表字段中

[英]How to update a constant value into sql table field by using copy activity in azure data factory

I have a SQL table which contains different fields along with Load_date. 我有一个SQL表,其中包含不同的字段以及Load_date。 I have data in CSV format and stored it in blob storage. 我有CSV格式的数据,并将其存储在Blob存储中。 Now the job is to copy data from CSV to SQL Table through azure data factory using copy activity. 现在的工作是使用复制活动通过azure数据工厂将数据从CSV复制到SQL表。 while performing this activity i want to dynamically populate the Load_date field because this fields is not available in CSV. 在执行此活动时,我想动态填充Load_date字段,因为该字段在CSV中不可用。

You cannot do that unless you use Data Flows: https://docs.microsoft.com/en-us/azure/data-factory/data-flow-derived-column 除非您使用数据流,否则您将无法做到这一点: https : //docs.microsoft.com/zh-cn/azure/data-factory/data-flow-derived-column

If data flows are too expensive, you can first insert the data in the table and then with a Stored Procedure fill all the null values in this Load_date field with getdate() or whatever data you want. 如果数据流太昂贵,则可以先将数据插入表中,然后使用存储过程用getdate()或所需的任何数据填充此Load_date字段中的所有空值。

I'll leave an example for your SP's update logic: 我将为您的SP的更新逻辑留下一个示例:

update [dbo].[YourTable] set [Load_date] = getdate() where [Load_date] is null

Then add a Stored Procedure activity in data factory, that will run after the copy activity finishes. 然后在数据工厂中添加一个存储过程活动,该活动将在复制活动完成后运行。

Hope this helped! 希望这对您有所帮助!

If the 'Load_date' field means current time, you can try to set a default value by using: 'getdate()' for this field in target table like below: 如果“ Load_date”字段表示当前时间,则可以尝试使用以下方法为目标表中的该字段使用“ getdate()”来设置默认值: 在此处输入图片说明

Thus you don't need to consider if source CSV file having this field or not, while rows inserting to target table, this field will filling with default value automatically. 因此,您无需考虑源CSV文件是否具有此字段,当在目标表中插入行时,该字段将自动填充为默认值。

暂无
暂无

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

相关问题 Azure 数据工厂复制活动失败将字符串(从 csv)映射到 Azure SQL 表接收器 uniqueidentifier 字段 - Azure Data factory copy activity failed mapping strings (from csv) to Azure SQL table sink uniqueidentifier field 有没有办法在使用 azure 数据工厂执行复制活动时保留 SQL 表的索引和键 - Is there a way to preserve indexes and keys of SQL table when performing a copy activity using azure data factory 如何在 Azure 数据工厂的复制活动中捕获 output 值 - How to capture an output value in Copy Activity in Azure Data Factory 如何使用Azure数据工厂复制活动提取电子邮件附件? - How to pull Email Attachments using Azure data factory copy activity? 在 Azure 数据工厂中复制数据活动后更新 - Update after a Copy Data Activity in Azure Data Factory Migrating Data from a SQL Server Encrypted Table to SQL Azure using Azure Data Factory Copy data - Migrating Data from a SQL Server Encrypted Table to SQL Azure using Azure Data Factory Copy data Azure数据工厂复制活动 - Azure Data Factory Copy Activity 将 JSON 映射到 SQL 的 Azure 数据工厂复制活动错误 - Azure Data Factory Copy Activity error mapping JSON to SQL Azure SQL 具有接收器存储过程的数据工厂复制活动 - Azure SQL Data Factory Copy Activity with Sink Stored Procedure 值 2150002867256 的复制活动中的类型转换错误:Azure 数据工厂 - Type Conversion Error in Copy activity for value 2150002867256: Azure data factory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM