New Line Issue when copying data from SQL Server 2012 to Excel

copy-paste, excel, sql, sql-server-2008, sql-server-2012

Solution

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

Problem

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. 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. 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.

Original source