易截截图软件、单文件、免安装、纯绿色、仅160KB

使用SQL Server导入/导出Excel

使用SQL Server导入/导出Excel,包含部分错误信息处理方法;
操作手记,留此备查
/*
导入
*/
--错误信息如下时:
--Msg 15281, Level 16, State 1, Line 2
--SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ad Hoc Distributed Queries' by using sp_configure. For more information about enabling 'Ad Hoc Distributed Queries', see "Surface Area Configuration" in SQL Server Books Online.
--请选择执行下面语句,修改默认配置,在进行导入操作
-- begin
sp_configure 'show advanced options',1
RECONFIGURE WITH override
go
sp_configure 'Ad Hoc Distributed Queries',1 -- 1:启用,默认0:禁用
RECONFIGURE WITH override
go
EXEC sp_configure;
go
-- end
-- 查询
select * from
OPENROWSET('MICROSOFT.JET.OLEDB.4.0','Excel 5.0;HDR=YES;DATABASE=D:\ExcelSheet1.xls',sheet1$)
go
-- 查询并导入
select * into ExcelSheet from
OPENROWSET('MICROSOFT.JET.OLEDB.4.0','Excel 5.0;HDR=YES;DATABASE=D:\ExcelSheet1.xls',sheet1$)
go
/*
导出
*/
--错误信息如下时:
--Msg 15281, Level 16, State 1, Procedure xp_cmdshell, Line 1
--SQL Server blocked access to procedure 'sys.xp_cmdshell' of component 'xp_cmdshell' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'xp_cmdshell' by using sp_configure. For more information about enabling 'xp_cmdshell', see "Surface Area Configuration" in SQL Server Books Online.
--请选择执行下面语句,修改默认配置,在进行导出操作
-- begin
sp_configure 'show advanced options',1
RECONFIGURE WITH override
go
sp_configure 'xp_cmdshell',1 -- 1:启用,默认0:禁用
RECONFIGURE WITH override
go
EXEC sp_configure;
go
-- end
--添加到现在Excel文档
insert into OPENROWSET('MICROSOFT.JET.OLEDB.4.0','Excel 5.0;HDR=YES;DATABASE=D:\ExcelSheet.xls',sheet1$)
go
--带连接信息导出
EXEC master..xp_cmd


相关文档:

航空公司管理系统(VC++ 与SQL 2005)

系统环境:Windows 7
软件环境:Visual C++ 2008 SP1 +SQL Server 2005
本次目的:编写一个航空管理系统
      这是数据库课程设计的成果,虽然成绩不佳,但是作为我用VC++ 以来编写的最大程序还是传到网上,以供参考。用VC++ 做数据库设计并不容易,但也不是不可能。以下是我的程序界面,后面 ......

sql查询慢的原因汇总


查询速度慢的原因很多,常见如下几种:
  1、没有索引或者没有用到索引(这是查询慢最常见的问题,是程序设计的缺陷)
  2、I/O吞吐量小,形成了瓶颈效应。
  3、没有创建计算列导致查询不优化。
  4、内存不足
  5、网络速度慢
  6、查询出的数据量过大(可以采用多次查询,其他的方法降低数据量) ......

帮助你从MySQL移植到SQL Server的工具(SSMA)

For SQL Server2008:
http://www.microsoft.com/downloads/details.aspx?FamilyID=0e6168b0-2d0c-4076-96c2-60bd25294a8e&displaylang=en
For SQL Server2005:
http://www.microsoft.com/downloads/details.aspx?familyid=C6F14640-DA22-4604-AAAA-A45DE4A0CD4A&displaylang=en ......

五种提高 SQL 性能的方法

本文节选自MSDN的文章《五种提高 SQL 性能的方法》,提出如何提高基于SQL Server应用程序的运行效率,非常值得推荐。对一些Traffic很高的应用系统而言,如何提高和改进SQL指令,是非常重要的,也是一个很好的突破点。
*文章主要包括如下一些内容(如感兴趣,请直接访问下面的URL阅读完整的中英文文档):
1, 从 INSE ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号