使用查询分析器代码从 SQL Server 2000 导出到 Excel [英] Export to excel from SQL Server 2000 using Query Analyzer code

查看:21
本文介绍了使用查询分析器代码从 SQL Server 2000 导出到 Excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将数据从 SQL Server 2000 导出到 Excel 的最简单方法是什么.

What's the easiest way to export data to excel from SQL Server 2000.

我想通过可以输入查询分析器的命令来执行此操作.

I want to do this from commands I can type into query analyzer.

我希望列名出现在第 1 行.

I want the column names to appear in row 1.

推荐答案

手动复制和粘贴是完全按照您的要求执行操作的唯一方法.当您复制结果时,查询分析器可以包含列名,但我认为您可能必须首先在选项中的某处启用它(我已经有一段时间没有使用它了).

Manual copy and paste is the only way to do exactly what you're asking. Query Analyzer can include the column names when you copy the results, but I think you may have to enable that somewhere in the options first (it's been a while since I used it).

其他选择是:

  1. 编写您自己的脚本或程序,将结果集转换为 .CSV 或 .XLS 文件
  2. 使用 DTS 包导出到 Excel
  3. 使用 bcp.exe(但它不包含列名,因此您必须kludge it)
  4. 使用链接服务器到空白 Excel 工作表并插入数据

一般来说,您不能使用纯 TSQL 将数据从 MSSQL 导出到平面文件,因为 TSQL 无法操作数据库之外的任何内容(使用链接服务器有点作弊).所以你通常需要使用某种客户端应用程序,无论是 bcp.exe、dtswiz.exe 还是你自己的程序.

Generally speaking, you cannot export data from MSSQL to a flat file using pure TSQL, because TSQL cannot manipulate anything outside the database (using a linked server is sort of cheating). So you usually need to use some sort of client application anyway, whether it's bcp.exe, dtswiz.exe or your own program.

作为最后的评论,不再支持 MSSQL 2000(除非您的公司有延长的维护协议),因此您可能希望在某个时候考虑升级.

And as a final comment, MSSQL 2000 is no longer supported (unless your company has an extended maintenance agreement) so you may want to look into upgrading at some point.

这篇关于使用查询分析器代码从 SQL Server 2000 导出到 Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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