将数据从SQL Server 2012复制到Excel时出现新行问题 [英] New Line Issue when copying data from SQL Server 2012 to Excel
问题描述
我最近升级到SQL2012,并且正在使用Management Studio。数据库中的一个列中存储了一个 CHAR(13)+ CHAR(10)
。
I recently upgraded to SQL2012 and am using Management Studio. One of my columns in the database has a CHAR(13) + CHAR(10)
stored in it.
当我使用SQL Server 2008时,这将完全复制并粘贴到Excel中。然而,现在,复制和粘贴相同的数据会在Excel中的数据中创建一个新的行/回车。
When I was using SQL Server 2008, this would copy and paste completely fine into Excel. Now, however, copying and pasting the same data creates a new line/ carriage return in the data I have in Excel.
有没有我在SQL2012中错过的设置,解决这个问题?我不想在每个单独的数据库选择上简单地 REPLACE(CHAR(13)+ CHAR(10))
,因为我必须从使用 SELECT *
来定义每个单独的列。
Is there a setting I missed in SQL2012 that will resolve this issue? I don't want to simply REPLACE(CHAR(13) + CHAR(10))
on every single database selection, as I would have to go from using SELECT *
to defining each individual column.
推荐答案
我最好的猜测是这不是一个错误,但是Sql 2012的一个功能.-)
在其他上下文中,您很乐意保留您的cr-lf,就像在复制大块文本时一样。只是它在你的情况下不能很好地工作。
My best guess is that this is not a bug, but a feature of Sql 2012. ;-) In other contexts, you'd be happy to retain your cr-lf's, like when copying a big chunk of text. It's just that it doesn't work well in your situation.
您可以随时将其从您的选择中删除。这将使您在两个版本中的查询:
You could always strip them out in your select. This would make your query for as you intend in both versions:
select REPLACE(col, CHAR(13) + CHAR(10), ', ') from table
这篇关于将数据从SQL Server 2012复制到Excel时出现新行问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!