SQLServerCentral Article

How to handle lost LF/CR when copying [code]

,

I like the tagging options and forums that came with the new SSC site. There is however one little downside when scripts are tagged within code ..... /code tags.

In one of the replies I did in the forums, I copied code from management studio and pasted it between code-tags.
Another participant copied my code from the forum and pasted it back into management studio.
He ended up with one line of code because linefeeds are not handled by management studio.

For small scripts, that may not be an issue.

With larger scripts, that may cause some of us losing precious time to get the script back to a runnable state. Maybe even aborting the test effort, and that's a shame.

A simple workaround is using a texteditor like MS Word.

Paste the code into a new word document.

Result: (if you show hiden characters)

Solution:

Replace (ctrl-H) ^l to ^p (replace all, mind you)

If you use Paste Special and paste unformatted text you can even skip the replace step !

Result: (if you show hiden characters)

Copy the code from the word document to your SSMS query pane and off you go.

 

 

 

 

 

Rate

4.5 (4)

You rated this post out of 5. Change rating

Share

Share

Rate

4.5 (4)

You rated this post out of 5. Change rating