0

Probably more of a SQL Management Studio question than SQL, per se, but when I run the following simple query:

SELECT results = 'Foo' + CHAR(13) + CHAR(10) + 'Bar'

I appear to get different results depending on whether I choose "Results to Grid" or "Results to Text".

With SSMS set to "Results to Text", I get (as expected):

results
--------
Foo
Bar

(1 row affected)

But with SSMS set to "Results to Grid", then copy and paste the results, I get

Foo  Bar
3

There is an option to change this behavior, go to Tools > Options > Query Results > SQL Server > Results to Grid, and check the box for "Retain CR/LF on copy or save":

enter image description here

You may have to exit and re-load SSMS for this change to take effect.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.