SQL Formatter error
When using OPENJSON with the WITH clause, the formatter does not recognize the WITH clause as valid SQL. This should format but throws an error:
DECLARE @JSONString NVARCHAR(MAX) SET @JSONString = N'{"Vendors":[{"VendorNumber":200,"VendorName":"Vendor1"},{"VendorNumber":201,"Vendo2"},{"VendorNumber":202,"VendorName":"Vendor3"}]}'
SELECT VendorNumber ,
VendorName
FROM OPENJSON(@JSONString, '$.Vendors')
WITH (VendorNumber INT '$.VendorNumber', VendorName VARCHAR(50) '$.VendorName')
This formatted error has been fixed in the latest version SQL Prompt 8:
https://forum.red-gate.com/discussion/80988/latest-stable-build-of-sql-prompt-is-8-0-0-1241-11th-may#latest
Thanks for your suggestion!
-
Scott Herbert commented
same problem here, version 7.4.1.603