问题描述
我想将一些 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!