使用SSIS从csv导入时,如何更新表中的数据? [英] how to update data in table while importing from csv using SSIS?

查看:286
本文介绍了使用SSIS从csv导入时,如何更新表中的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个csv文件,我必须从中将数据存储到表中[USERS].
该文件每天生成,并对用户详细信息记录进行一些更新.
我已经很好地完成了部分导入,但是每次运行此项目时,它都会再次插入整个数据,而不仅仅是UPDATE.



说第1天的csv文件是

1,sushil,sainju,sushil @ gmail.com
2,subash,stha,subash @ gmail.com
此文件已很好地导入到表中,但是当我对csv文件进行少量更新后运行此项目时

1,sushil,sainju,sushil @ gmail.com
2,subash,aaaa,SHAK @ hotmail.com

该项目会将另外2条记录添加到表中,而不是更新现有记录.有人可以帮我吗?
:)

i have a csv file from which i have to store data to my table[USERS].
this file is generated daily with some updates to records of user details.
i have done importing part quite well but every time i run this project it INSERTS whole data over again instead of just UPDATE.



say the csv file for day 1 is

1,sushil,sainju,sushil@gmail.com
2,subash,stha,subash@gmail.com
this file is imported to the table quite well but when i run this project after making few updates to the csv file
say
1,sushil,sainju,sushil@gmail.com
2,subash,aaaa,SHAK@hotmail.com

the project will add 2 more records to the table instead of updating the existing records. can anyone pls help me with this?
thanks in advance.:)

推荐答案

定义使一行(记录)唯一的原因,例如行首的数字.为确保仅表(唯一数字除外)将数字字段定义为表的主键.

然后使用该编号在表中进行搜索.如果存在,请使用文件中的信息更新记录.如果不存在,则在表中插入新记录.
Define what makes a line (record) unique, for example the number at the beginning of the line. To make sure that the table only excepts unique numbers define the number field as the primary key of your table.

Then use this number to search for it in the table. If it exists update the record with the information from the file. If it does not exist insert a new record in the table.


这篇关于使用SSIS从csv导入时,如何更新表中的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆