易截截图软件、单文件、免安装、纯绿色、仅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


相关文档:

SQL Server 2005中的文件和文件组(二)

--> Title  : SQL Server 2005中的文件和文件组(二)
--> Author : wufeng4552
--> Date   : 2010-1-13
SQL Server 2005中的文件和文件组(ㄧ) 主要講解了理論部分
http://blog.csdn.net/wufeng4552/archive/2009/10/23/4716053.aspx
SQL Server 2005中的文件和文件组(二) 主要 ......

sql查询慢的原因汇总


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

SQL Server 2008的四项新特性

在SQL Server 2008中,不仅对原有性能进行了改进,还添加了许多新特性,比如新添了数据集成功能,改进了分析服务,报告服务,以及Office集成等等。
  SQL Server集成服务
 
 SSIS(SQL Server集成服务)是一个嵌入式应用程序,用于开发和执行ETL(解压缩、转换和加载)包。SSIS代替了SQL
2000的DTS。整合服务功能既包 ......

五种提高 SQL 性能的方法

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

SQL Server里的 ISNULL 与 Oracle 中的 NULLIF

SQL Server里的 ISNULL 与 Oracle 中的 NULLIF不同:
  SQL Server 中有两个参数,语法:
    ISNULL(check_expression, replacement_value)
    check_expression 与 replacement_value 数据类型必须一致
   
如果 check_expression 为 NULL,则返回 replacement_v ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号