Article

Comparing two SQL scripts line by line

A script review is easier when both sides are formatted the same way. Diff Viewer compares two scripts line by line. The full page includes the Monaco editor, SQL formatting, and a semantic check so a change in meaning is not hidden by a change in layout.

Whitespace is not the review

Two warehouse scripts can be the same query with different wrapping. A raw diff then looks like a rewrite.

Format both sides first. Then the remaining lines are the join, the filter, or the column list that actually changed.

What Diff Viewer does

Paste the original and the updated script. The page formats SQL and shows a line-by-line diff. A semantic check flags differences that are more than layout.

The tool is the same one I use when a stored procedure comes back from a change and I need to see what moved before it is scheduled.

Questions

How do you compare two SQL scripts?

Format both sides, then diff them line by line. Diff Viewer does that in the browser and includes a semantic check.

Why format SQL before a diff?

Different wrapping makes a raw diff look like a rewrite. After both scripts are formatted, the remaining lines are the real change.

Who created Diff Viewer?

Timothy Kirk. It is a free browser tool at timothykirk.co.uk/diffview/.