SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

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

By Johan Bijnens,

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)


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.






Total article views: 1286 | Views in the last 30 days: 3
Related Articles

Using SQL Server Management Studio Projects

One of the most underutilized assets in SQL Server Management Studio is the SSMS project. Within Man...


How to Access Active Directory with management studio 2008

Active Directory Sql Management studio


SQL Server Management Studio add-ins

Complete list of useful and must have add-ins for SQL Server Management Studio - 34 SSMS add-ins


Licensing SQL Sever Management Studio.

Licensing SQL Sever Management Studio.