Question

The title is a little confusing but essentially I know what is happening just don't know how to prevent it from happening.

When I copy the following column from SQL Server: (the data is all in one column)

Rows | Column A
Row1 | 1. Description: Customer 2. Replicate issue: recreated 3. Other issues: no other

and paste it into Excel it looks like this:

Rows | Column A
Row1 | 1. Description: Customer 
Row2 | 2. Replicate issue: recreated 
Row3 | 3. Other issues: no other

I would like the paste to be identical to the column from SQL Server, however I do not know how to remedy this...I have toyed with some text to columns stuff but 1) I don't know what I'm doing there and 2) I don't think that is it....

I have also tried saving as a .txt file and import it that way and no dice.

Thanks in advance!

Was it helpful?

Solution 2

As Sekar mentioned above, that works. In addition I have found that by using: replace(replace(replace([Column],CHAR(9),'',''),CHAR(10),'',''),CHAR(13),'','')

Replaces all of the carriage returns (which is what was causing my issue) with a single space. Thus when I paste into Excel, issue resolved. Originally I had figured out the CHAR(10) and CHAR(13) workaround when I start seeing it again :(

That's when I cam across the CHAR(9) workaround as well as the following information posted the other day on Microsoft Connect

Posted by JayakumarPanasonic on 3/7/2015 at 3:14 AM

IT IS A BUG AND MS IS STILL SILENT.

Yesterday whole day I spent to extract some data form SQL2012, where I faced same issue. Used CHAR(9), CHAR(10), and CHAR(13) to resolve it temporarily. Really surprised, why MS is taking this so lite and not fixed yet. It used to work fine with SQL2008. Give option SQL2012 configurable through: Tools | Options... or provide additional options, while pasting data in Excel.

OTHER TIPS

Try like this.

This is working for me.

select top 10 replace([Column], CHAR(10),', ') as [AliasName] FROM TableName

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top