SQLServer2008导入Excel数据

 

1、编写语句:

SELECT * into newtable

FROM OpenDataSource'Microsoft.Jet.OLEDB.4.0',

'Data Source="G:\唐山宣传信息手机彩信\第一期\唐山市委宣传系统电话.csv";User ID=Admin;Password=;Extended properties=Excel 5.0')...[se$]

 

2、出现错误提示

消息 15281,级别 16,状态 1,第 2 行
SQL Server 阻止了对组件 'Ad Hoc Distributed Queries' 的 STATEMENT 'OpenRowset/OpenDatasource' 的访问,因为此组件已作为此服务器安全配置的一部分而被关闭。系统管理员可以通过使用 sp_configure 启用 'Ad Hoc Distributed Queries'。有关启用 'Ad Hoc Distributed Queries' 的详细信息,请参阅 SQL Server 联机丛书中的 "外围应用配置器"。

 

SQL2008:

打开SQL Server Management Studio-->在左边[对象资源管理器]中选择第一项(主数据库引擎)-->右键-->方面-->在方面的下拉列表中选择[外围应用配置器]-->将'Ad Hoc Distributed Queries'置为True.
http://apps.hi.baidu.com/share/detail/34809468

参考文章:

http://blog.csdn.net/43720938/archive/2008/01/29/2072129.aspx

http://hi.baidu.com/freezesoul/blog/item/085e4a54b51ef45c564e00f7.html

http://www.cnblogs.com/hongweiqu/archive/2009/08/22/1552175.html

 

 

--查询具体相同电话号人的。
 

--查询具体相同电话号人的。
 select * from phone
where hphone in(select hphone from phone  group by hphone having count(*)>1)

 

 

 选择数据库→右键→任务→导入→选 execls文件
 

posted @ 2011-05-19 16:21  C#&SQL  阅读(1238)  评论(0编辑  收藏  举报