本文介绍了通过excel文件导入时,如何更新SQL表中的现有记录。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 你好, 我正在开发一个上传机制,用户可以点击按钮将excel文件上传到sql表。 excel文件包含列 Ref#,EndDate,StepName 和 StepResponse 。 我的SQL表有列 Ref#,Login_Date, Decision_Date StepName 和 StepResponse 。 excel文件将每天上传到数据库中。 列 StepName 可以有 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 。 我希望我已经解释得很好,如果不是,请不要犹豫,我会尽力避免任何混淆。 期待您的平常支持。 谢谢 我尝试了什么: 已通过互联网搜索但无法找到任何相关解决方案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.ThanksWhat 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表中的现有记录。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-05 12:30