Repository navigation
Description
Summary
SqlScriptGenerator always writes join types in their long form:
No SqlScriptGeneratorOptions setting changes this. The two forms mean exactly the same thing. Still, teams whose convention is the short form get large, noisy diffs the first time they adopt a ScriptDOM-based formatter.
Impact
ScriptDOM is now the engine behind the built-in SQL formatter in the MSSQL extension for VS Code (through SQL Tools Service) and in SSMS. As a result, any team that adopts these formatters is pushed onto the long join form whether they want it or not. Effects:
- Existing codebases get diffs where only the join keywords change, which pollutes code review and
git blame. - Plain-text searches for
LEFT JOINacross a repository stop matching the rewritten code. - Teams that use the short form can’t adopt the formatter without changing their coding standard.
Root cause
In SqlScriptGeneratorVisitor.QualifiedJoin.cs, the token lists in _qualifiedJoinTypeGenerators are hard-coded:
{ QualifiedJoinType.LeftOuter, { Left, Outer } },
{ QualifiedJoinType.Inner, { Inner } },
{ QualifiedJoinType.RightOuter, { Right, Outer } },
{ QualifiedJoinType.FullOuter, { Full, Outer } },QualifiedJoin (in Ast.xml) only stores the QualifiedJoinType enum, so the generator can’t tell whether the source used the optional keyword.
Proposal
Add a new option to SqlScriptGeneratorOptions, for example:
public JoinKeywordStyle JoinKeywordStyle { get; set; } = JoinKeywordStyle.Full;
public enum JoinKeywordStyle
{
Full, // current behavior: LEFT OUTER JOIN, INNER JOIN
Short, // LEFT JOIN, RIGHT JOIN, FULL JOIN, JOIN
}- The default
Fullkeeps the current output unchanged, so existing users aren’t affected. Shortonly needs a different token list inGenerateQualifiedJoinType. No AST change is required.- A possible later step is a
Preservevalue that keeps whatever the source used. That would require recording onQualifiedJoinwhether the optional keyword was present.
Downstream, SQL Tools Service and the MSSQL extension for VS Code could then expose this as mssql.format.options.joinKeywordStyle, next to the existing newLineBeforeJoinClause, newLineAfterJoinKeyword and newLineBeforeOnClause options.
Repro
SELECT a.id, b.name
FROM dbo.A a
LEFT JOIN dbo.B b ON b.id = a.id
JOIN dbo.C c ON c.id = a.id;Parse with TSql170Parser and generate with Sql170ScriptGenerator using default options. Output contains LEFT OUTER JOIN and INNER JOIN.
Environment
- ScriptDOM
main@3ea69b6(2026-10-21) - Observed through the MSSQL extension for VS Code SQL formatter (SQL Tools Service
main@13be8a3)

Activity