You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TransactSQL table WITH (NOLOCK) is formatted as WITH-clause. #867
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) ontable2.id=table1.id
Expected Output
SELECT*FROM
table1 WITH (NOLOCK)
LEFT JOIN table2 WITH (NOLOCK) ONtable2.id=table1.id
Actual Output
SELECT*FROM
table1
WITH
(nolock)
LEFT JOIN table2
WITH
(nolock) ONtable2.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
changed the title [-]TransactSQL WITH (NOLOCK) is formatted as WITH-clause.[/-][+]TransactSQL `table WITH (NOLOCK)` is formatted as WITH-clause.[/+]on May 22, 2025
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.
Activity
[-][FORMATTING] Issue Title Here[/-][+]TransactSQL WITH (NOLOCK) is formatted as WITH-clause.[/+][-]TransactSQL WITH (NOLOCK) is formatted as WITH-clause.[/-][+]TransactSQL `table WITH (NOLOCK)` is formatted as WITH-clause.[/+]nene commentedon May 22, 2025
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.