如何验证Excel工作表 [英] how to validate excel sheet

查看:93
本文介绍了如何验证Excel工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张Excel工作表,其中有国家/地区列表.我想在sql server中添加国家/地区数据,但在存储数据时会检查数据库中是否已存在国家/地区验证?然后存储到db中.

i have excel sheet there are list of countries. i want to add country data in sql server but at the time of storing data it check validation like country is already exist in database or not? then store into db.

推荐答案

我不久前回答的一个类似问题:
A similar question that I answered not very long ago: How to import excel data to SQL database table[^]

Once you understand how to do this, you can easily validate the data before saving as well. You just have to loop through the collection and see if that country exists in the db or not. And the way you check whether it exists in db or not, is to do a select query for that name and see if any results are returned (pretty basic really).


不是难..难一个...
1.转到"SQL Server Management Studio"
2.右键单击您的数据库名称,然后选择任务->导入数据"
3.现在选择"Microsoft Excel"作为数据源
4.在Excel文件路径中浏览并提供excel文件(输入)
5.选择适当的excel版本,并提供下一步"
6.现在选择目标"作为"SQL Server Native Client 10.0"
7.选择适当的服务器名称,数据库名称,身份验证并提供下一步".
8.现在选择写查询以指定要传输的数据"
9.现在给我们查询
10.给出3次下一步",然后完成"

现在,您已成功将数据插入到创建的新表中.如果您想将数据添加到已经存在的表中,请在执行第9步后(即查询完后),从下一步显示的目标列中选择目标.通常它会显示一个新的表名,但是您可以从下拉列表中选择已经存在的表....

如有任何疑问,请答复
如果您觉得有用,请标记它.
It is not that difficult.. easy one...
1.go to "SQL Server Management studio"
2.Right click on ur database name and select "Tasks -> Import Data"
3.Now select "Microsoft Excel" as DataSource
4.In Excel file path browse and give ur excel file(input)
5.Select appropriate excel version and give "Next"
6.Now select Destination as "SQL Server Native Client 10.0"
7.Select appropriate Sever name, DB name, Authentication and give "Next".
8.Now select "Write a query to specify the data to Transfer"
9.Now give ur query
10.give 3 times "Next" and then "Finish"

Now u have successfully inserted data to a new table created. If u want to add data to already existing table, after step 9 i.e. after giving ur query, select destination from the destination column displayed in the next step. Usually it shows a new table name but u can select already existing tables from the drop down list....

For any clarifications reply to this,
Mark it if u find it useful.


这篇关于如何验证Excel工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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