TransactSQL `table WITH (NOLOCK)` is formatted as WITH-clause.
Which SQL and options did you provide as input? I am using the SQL Formatter VSCode extention with default settings except for the three following: "SQL-Formatter-VSCode.dialect": "transactsql", "SQL-Formatter-VSCode.functionCase": "upper", "SQL-Formatter-VSCode.keywordCase": "upper",
The TransactSQL dialect does not seem to handle WITH (NOLOCK) appropriately. I think it considers it as a WITH statement, and it does not uppercase nolock automatically. For example:
Input data
select *
from table1 with (nolock)
left join table2 with (nolock) on table2.id = table1.id
Expected Output
SELECT
*
FROM
table1 WITH (NOLOCK)
LEFT JOIN table2 WITH (NOLOCK) ON table2.id = table1.id
Actual Output
SELECT
*
FROM
table1
WITH
(nolock)
LEFT JOIN table2
WITH
(nolock) ON table2.id = table1.id
Usage
- How are you calling / using the library? I am using the SQL Formatter VSCode extention.
- What SQL language(s) does this apply to? TransactSQL
- Which SQL Formatter version are you using? The extension is v4.2.0
Thanks for reporting.
You're right in your diagnosis that the formatter thinks that this is a WITH-clause. Unfortunately this problem is pretty tricky to solve with the current architecture of the formatter.