SSMS Results to Grid - CRLF not preserved in copy/paste - any better techniques?

Posted by Cade Roux on Stack Overflow See other posts from Stack Overflow or by Cade Roux
Published on 2010-04-20T23:53:28Z Indexed on 2010/04/21 3:13 UTC
Read the original article Hit count: 350

Filed under:
|
|
|

When I have a result set in the grid like:

SELECT 'line 1
line 2
line 3'

or

SELECT 'line 1' + CHAR(13) + CHAR(10) + 'line 2' + CHAR(13) + CHAR(10) + 'line 3'

With embedded CRLF, the display in the grid appears to replace them with spaces (I guess so that they will display all the data).

The problem is that if I am code-generating a script, I cannot simply cut and paste this. I have to convert the code to open a cursor and print the relevant columns so that I can copy and paste them from the text results.

Is there any simpler workaround to preserve the CRLF in a copy/paste operation from the results grid?

The reason that the grid is helpful is that I am currently generating a number of scripts for the same object in different columns - a bcp out in one column, an xml format file in another, a table create script in another, etc...

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about SSMS