将数据从Excel导入Sql-2005数据库 [英] Import data from Excel to Sql-2005 Database

查看:108
本文介绍了将数据从Excel导入Sql-2005数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将excel数据导入sql-2005表中.

我知道如何使用GUI进行操作,但是我面临的问题是我在表中定义了一个主键,因此当我从excel导入数据时,如果它具有重复数据,则由于主键而失败.

否则,它将成功导入.

所以我想编辑excel文件中的记录并在excel中添加新记录.
如果进行了编辑,我希望在导入过程中在table(sql)中对其进行更新,否则,我希望在导入过程中将记录插入到table(sql)中.

我该怎么做.

I want to import excel data into sql-2005 table.

I know how to do it with GUI but the problem I am facing is I have a primary key defined in my table hence when I import data from excel if it has duplicate data it fails due to primary key.

Otherwise it imports successfully.

So I want to edit records in excel file and add new records in excel.
If edited, I want it to be updated in table(Sql) during import process, otherwise I want the record to be inserted in table(sql) during import process.

How can I do this.

推荐答案

您可以使用SSIS执行此任务.它比Management Studio中的默认导入/导出"组件更为先进.

但是,如果您要执行的只是临时操作(一次),则最好创建一些批处理工具或重新加载整个表.
You can use SSIS to perform this task. It''s more advanced then the default Import/Export component from the Management Studio.

But if what you are trying to do is only a temporary (one time) action, you might be better of just creating some batch tool or just reloading the whole table.


这篇关于将数据从Excel导入Sql-2005数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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