从文本文件导入数据时,我想更新数据库表 [英] When Importing Data From Text File I Want To Update Database Table

查看:128
本文介绍了从文本文件导入数据时,我想更新数据库表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从文本文件导入数据时,我想用新记录(旧+新记录)更新数据库表,并在C#Windows窗体应用程序中计算从文本文件导入的新记录的数量.

我不想导入数据库中已经存在的记录.

数据库表中没有主键约束.

谁能帮我解决这个问题.



谢谢.

when importing data from text file i want to update database table with new records(old + new records) and count the no of new records imported from textfile in C# windows form application.

I don''t want to import records which are already present in database.

No primary key constraint in database table.

can any one help me to solve this problem.



Thanks.

推荐答案

1.将txt加载到临时表中.

2.在sql server中使用"except"关键字来获取实际"表中不存在且在临时"表中已存在的记录.
例如
ActualTable中
1. Load the txt into a temporary table.

2. Use the "except" key word in sql server to get the records which are not existing in Actual table and existing in Temporary table.
e.g.
Select col1,col2, col3 from ActualTable
          Except
Select col1,col2, col3 from TemporaryTable




3.然后将步骤2的结果记录插入ActualTable.




3. Then insert the resultant records of step 2 into ActualTable.


这篇关于从文本文件导入数据时,我想更新数据库表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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