shortcut to remove empty lines from sql query window

Most of you would have seen that while pasting the result of sp_helptext in query window, it throws up lot of blank lines. The following steps would help to format the result.

 

1.       Create a batch file with the following lines,

 

            @echo off

            findstr /v /r /c:"^$" /c:"^\ *$" /c:"^\       *$" %1 > %temp%\delblanklinestmp.txt

            copy /Y %temp%\delblanklinestmp.txt %1

            del /Q %temp%\delblanklinestmp.txt

 

2.       Save the batch file, say  c:\temp\DelBlankLines.bat

3.       From SSMS,  add the above batch file as an external tool to be executed. Refer the image below for the parameters

 

 

 

 

 

4.       Map the command to a hot key as shown below,

 

 

 

5.       You are all set to test..

6.       From query window, execute sp_helptext  <procedure>   (having result in grid would be better)

7.       Copy the text from the result window and paste into the query window.

8.       Save the query window.  If there are no irritating blank lines, create few for testing.

9.       Click Ctrl+F12.

10.     Reload to see the change..