Pasting TSQL into SSMS results in blank lines - How to get rid of them

Often when you paste TSQL code from Word, an email or off the web you often find blank lines are inserted in the code.

I think the issue is due to parsing paragraphs and non pagaraph breaks i.e. <p> and <br> They have different meaning in HTML/Word world where <p> has extra space after it (normally). But with text there is no way to specify any difference in text world to give the extra space after pargraphs they stick in another carriage return.

There is a simple solution, you can get rid of these by doing a search and replace

Search for \n:b*\n and replace \n and make sure use regular expressions is checked

The :b* allows for the odd tab or space on the blank lines


-
Published 21 May 2009 10:49 by simonsabin
Filed under:

Comments

21 May 2009 17:05 by DonRWatters

# re: Pasting TSQL into SSMS results in blank lines - How to get rid of them

Or, you can use puretext.

www.stevemiller.net/puretext

21 May 2009 17:20 by simonsabin

# re: Pasting TSQL into SSMS results in blank lines - How to get rid of them

Very true, I had heard there was something but didn't know what it was.

Thanks