Search code examples
sqlmergediffnewlineword-diff

Diff Tool That Ignores Newlines


I frequently need to compare SQL procedures to determine what has changed in the newest version. The problem is, everyone has their own style of formatting, and SQL doesn't (usually) care about where one puts their newlines (e.g. where clauses all on one line vs. newline before each AND).

This makes it very difficult (especially for long procedures) to see the actual differences. I cannot seem to find a free diff/merge utility that will allow me to ignore newlines (i.e. treat as whitespace). So far I've tried WinMerge and Beyond Compare without any luck. Does anyone know of a diff tool (ideally free) that would see these two examples as identical?

Ex. 1:

the quick
brown

Ex. 2:

the
quick
brown

Thanks in advance.


Solution

  • What i've done in my own similar case is to use a sql prettifier which will organize two sets of semi-disparate SQL in very similar fashion automatically. i then paste and compare the results with WinMerge.

    It's a two-step process but it's much more palatable than many other options, especially when many lines of code are involved.

    Link to web-based Sql Pretty printer that's decent.