TSQL formatting per line

Our company uses an old application that reads TSQL from an INF file. Due to the way the application processes the INI file, TSQL must be on the same line. I use the Blans Mans TSQL Formatter so that everything is nice and neat for things like SP, but I wonder if there is anything there to do the opposite - take the beautifully formatted TSQL and drag it all onto one line (delete carriages, line breaks, etc.), I work in SSMS, but I also use Notepad ++ and I am happy to use some other editor if it has functionality.

+5
source share
5 answers

Using Notepad ++

, , : TextFX > TextFX Edit > Unwrap Text

enter image description here

mapper ( > Mapper)

enter image description here

+9

minify Bad Mans TSQL Formatter

[minify]

[/minify]
+2

Notepad ++ ( - )

, TextFX , PoorMansTSqlFormatter x64- ++ .

Notepad ++ → Write Query → Edit → Blank Options → Remove Unnecessary Blank EOL.

enter image description here

.

+2

SQL Server 2012:

  • " " (ctrl + h)

  • Check: use regular expressions

  • Find: \ n

  • Replace with: LEAVE BLANK

+1
source

I like Martin's answer, and this is probably the way to go. But I will point out that you can simply use string manipulations to convert carriage returns and linear feeds to spaces. This is especially useful in later versions of SSMS, which restrict the use of regular expressions in the find / replace dialog box.

0
source

All Articles