通过excel文件导入时,如何更新SQL表中的现有记录。 [英] How do I update the existing records in SQL table when importing through excel file.
问题描述
你好,
我正在开发一个上传机制,用户可以点击按钮将excel文件上传到sql表。
excel文件包含列 Ref#,EndDate,StepName 和 StepResponse 。
我的SQL表有列 Ref#,Login_Date, Decision_Date StepName 和 StepResponse 。
excel文件将每天上传到数据库中。
列 StepName < excel文件中的/ i>可以有 BureauPull 或 Level2 等记录。
Ref#是excel中的唯一列文件。 Excel文件正在从另一个系统下载,然后下载,然后每天上传到SQL表格。
现在让我们假设,我有一个带有 Ref#='abc123'的案例和 StepName ='BureauPull',每当 StepName = BureauPull , EndDate 将与 Login_Date 一起映射在SQLTable中,只要 StepName = Level2 , EndDate 将与 Decision_Date 映射。
现在让我们说当我在第二天下载此excel文件,同一案例的StepName,即 Ref#='abc123'从'BureauPull'更改为'Level2'所以当我在SQL表中上传这个文件时,我需要更新以前上传的案例。现在 EndDate 将映射到 Decision_Date 。
我希望我已经解释得很好,如果不是,请不要犹豫,我会尽力避免任何混淆。
期待您的平常支持。< br $>
谢谢
我尝试了什么:
已通过互联网搜索但无法找到任何相关解决方案
Hello,
I am developing an upload mechanism, where user will upload excel file into sql table using a button click.
The excel file has columns Ref #, EndDate,StepName and StepResponse.
And my SQL table has columns Ref#, Login_Date, Decision_Date StepName and StepResponse.
The excel file will be uploaded daily in the database.
The Column StepName in excel file can have records like BureauPull or Level2.
Ref# is unique column in excel file. Excel file is being downloaded from another system and it is downloaded and then uploaded into SQL table on daily basis.
Now lets assume, i have a Case with a Ref#='abc123' and StepName = 'BureauPull' and whenever StepName = BureauPull then the EndDate will be mapped with Login_Date in SQLTable and whenever the StepName = Level2 the EndDate will be mapped with Decision_Date.
Now lets say when i download this excel file on the second day and the StepName of same case i.e. Ref#='abc123' changes from 'BureauPull' to 'Level2' so when i upload this file in SQL table then i need to update the previous uploaded case aswell. Now the EndDate will be mapped to Decision_Date.
I hope i have explained it well, if not please don't hesitate to ask and i will try to clear any confusion.
Looking forward to your usual support.
Thanks
What I have tried:
Have searched through internet but unable to find any relevant solution
推荐答案
上传您的Excel文件到与Excel文件具有相同列的阶段表。
使用 MERGE [ ^ ]插入或更新到最终表格。
第二天,在插入下一个Excel文件之前截断阶段表。
Upload your excel file to a stagetable with the same columns as the Excel file.
Use MERGE[^] to insert or update to the final table.
The next day you truncate the stagetable before inserting the next Excel file.
这篇关于通过excel文件导入时,如何更新SQL表中的现有记录。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!