如何获得“真实”的输出输出CSV格式在SQL Server管理工作室? [英] How to get export output in "real" CSV format in SQL Server Managment Studio?

查看:294
本文介绍了如何获得“真实”的输出输出CSV格式在SQL Server管理工作室?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个查询,我在SQL Server Management Studio中运行(连接到SQL Server 2005数据库)。我想导出CSV格式的数据。不是wannabe的CSV格式,你只需在每列之间粘一个逗号,但真正的CSV格式,你在你的字符串的引号。这样,您可以导出其中包含逗号或引号的数据。



我看到的所有示例仅限于wannabe格式。我不知道引用字符串的选项在哪里。



如果SSMS真的不能这个基本专长,还有其他工具,它会很容易吗?我不想在每次需要数据转储时都编写一个C#程序。



谢谢!

选项 - >查询结果 - > SQL Server - >结果到网格中,它被称为包含列表分隔符的报价字符串.csv results。我不知道这样的选项存在多久,但我被两件事情困惑:


  1. 怎么不转动




p>它只是反驳相信默认行为是CSV导出,是不可能正确导入。我注意到Excel也是一样的,我必须去看看是否有一个选项。



同时,感谢我的同事指出我这是一个奇怪的功能,当我在谈论如何CSV导出器是完全无用的,这是我发现的最好的链接,所以我想我会把这里的知识,为未来的搜索者的利益。 p>

I have a query that I am running in SQL Server Management Studio (connecting to a SQL Server 2005 database). I want to export the data in CSV format. Not wannabe CSV format, where you just stick a comma between each column, but "real" CSV format, where you put quotes around your strings. This way you can export data that has commas or quotes in it.

All the examples I see limit themselves to the wannabe format. I can't figure out where the option to quote strings is.

If SSMS is truly incapable of this basic feat, are there other tools that will do it easily? I don't want to have to write a C# program every time I need a data dump.

Thanks!

解决方案

In SSMS 2012 there's an option for this, in Tools -> Options -> Query Results -> SQL Server -> Results to Grid, it's called "Quote strings containing list separators when saving .csv results". I don't know how long such an option has existed for, but I'm baffled by two things:

  1. How come it's not turned on by default
  2. How come it's an option and not an intrinsic part of the CSV exporting code

It just defies belief that the default behaviour is to have CSV export that's impossible to import properly. I've noticed Excel does the same, I'll have to go see if that's got an option too.

In the mean time, thanks to my colleague who pointed me to this bizarre bit of functionality when I was ranting about how the CSV exporter was completely useless, and this was the best link I'd found about it so I thought I'd put the knowledge here for the benefit of future searchers.

这篇关于如何获得“真实”的输出输出CSV格式在SQL Server管理工作室?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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