如何将 SQL Server 2005 查询导出为 CSV

How to export SQL Server 2005 query to CSV(如何将 SQL Server 2005 查询导出为 CSV)
本文介绍了如何将 SQL Server 2005 查询导出为 CSV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将一些 SQL Server 2005 数据导出为 CSV 格式(逗号分隔,用引号).我可以想到很多复杂的方法来做到这一点,但我想以正确的方式去做.我看过 bcp,但我不知道如何在字段周围加上引号(除了将它们连接到字段值,这很丑陋).我想我可以用 sqlcmd 和 -o 来做到这一点,但出于同样的原因,这看起来很丑陋.

I want to export some SQL Server 2005 data to CSV format (comma-separated with quotes). I can think of a lot of complicated ways to do it, but I want to do it the right way. I've looked at bcp, but I can't figure out how to put the quotes around the fields (except concatenating them to the field values, which is ugly). I guess I could do it with sqlcmd and -o, but that seems ugly for the same reason.

有bcp的方法吗?

是否有合理的 sqlcmd 方法?

Is there a reasonable sqlcmd way to do it?

是否有一些很棒的、简单的实用程序内置到我刚刚忽略的 Management Studio 中?

Is there some great, simple utility built into the Management Studio that I'm just overlooking?

推荐答案

在 Management Studio 中,选择数据库,右键单击并选择 Tasks->Export Data.在那里,您会看到导出为不同类型格式的选项,包括 CSV、Excel 等.

In Management Studio, select the database, right-click and select Tasks->Export Data. There you will see options to export to different kinds of formats including CSV, Excel, etc.

您还可以从查询"窗口运行查询并将结果保存为 CSV.

You can also run your query from the Query window and save the results to CSV.

这篇关于如何将 SQL Server 2005 查询导出为 CSV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Execute complex raw SQL query in EF6(在EF6中执行复杂的原始SQL查询)
SSIS: Model design issue causing duplications - can two fact tables be connected?(SSIS:模型设计问题导致重复-两个事实表可以连接吗?)
SQL Server Graph Database - shortest path using multiple edge types(SQL Server图形数据库-使用多种边类型的最短路径)
Invalid column name when using EF Core filtered includes(使用EF核心过滤包括时无效的列名)
How should make faster SQL Server filtering procedure with many parameters(如何让多参数的SQL Server过滤程序更快)
How can I generate an entity–relationship (ER) diagram of a database using Microsoft SQL Server Management Studio?(如何使用Microsoft SQL Server Management Studio生成数据库的实体关系(ER)图?)