How can I remove empty lines in SQL Server Management Studio (SSMS)?

You can do it using the regular expression in SSMS:

  1. Ctrl-H to bring up the Find And Replace window
  2. Select USE -> Regular Expressions
  3. Put ^\n in the Find What
  4. Keep Replace With empty
  5. Click Replace (All)

Good luck


I have gone through the below steps, and it worked for me.

  1. Menu ToolsCustomizeCommandsAdd commandEditDelete blank lineOK.
  2. The Delete Blank Lines menu appears in beside the File menu.
  3. Open/Select Query - Click "Delete Blank Lines".
  4. Enjoy.

You can use: Find and replace

  • Find what: \n\n
  • Replace with: \n
  • use: 'regular expressions'

it is described here:

http://my.safaribooksonline.com/book/databases/microsoft-sql-server/9781617290473/using-regular-expressions-in-ssms/ch21lev1sec1#X2ludGVybmFsX0h0bWxWaWV3P3htbGlkPTk3ODE2MTcyOTA0NzMlMkZjaDIxbGV2MXNlYzImcXVlcnk9