[英]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.