How to remove double spacing after pasting code

If you copy and paste T-SQL code around frequent enough, I am sure you would have seen the double spacing issue.

For example:

select name

from sys.databases

where database_id = 1

order by name

The quickest way to remove double spacing is by using the “Find and Replace” function found in SQL Server Management Studio (SSMS):

  1. Find and Replace: Ctrl+H
  2. Find what: \n\n
  3. Replace with: \n
  4. Find options: Use Regular expressions
  5. Replace All: Ctrl+A


Bob is your uncle.