-
Notifications
You must be signed in to change notification settings - Fork 961
Description
Title:
Large JSON output from FOR JSON PATH automatically splits into multiple rows in SSMS 22 Preview
Product and Version
- Product: SQL Server Management Studio (SSMS)
- Version: SSMS 22 Preview (latest build as of October 2025)
- SQL Server Engine Version: SQL Server 2019 / 2022 (tested on both)
- Operating System: Windows 10 / Windows 11
Issue Description
When executing a query that generates a large JSON result using FOR JSON PATH, SSMS 22 Preview splits the JSON output into multiple rows in the Results (Messages) grid.
In previous SSMS versions (e.g., SSMS 18.x / 19.x), the entire JSON output appeared as a single cell or line, properly formatted as one continuous JSON string.
This behavior causes issues when copying or exporting JSON output because it is truncated or fragmented across multiple rows, making it invalid JSON unless manually reconstructed.
Steps to Reproduce
-
Run the following script in SSMS 22 Preview:
IF OBJECT_ID('tempdb..#UserList') IS NOT NULL DROP TABLE #UserList; CREATE TABLE #UserList ( user_code INT, user_name NVARCHAR(100), user_email NVARCHAR(100) ); ;WITH Numbers AS ( SELECT TOP (20000) ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) AS num FROM sys.objects a CROSS JOIN sys.objects b ) INSERT INTO #UserList (user_code, user_name, user_email) SELECT num, CONCAT('User_', num), CASE WHEN num % 5 = 0 THEN NULL ELSE CONCAT('user', num, '@example.com') END FROM Numbers; SELECT ROW_NUMBER() OVER (ORDER BY user_code) AS row_num, user_code, user_name, user_email FROM #UserList ORDER BY user_code FOR JSON PATH, INCLUDE_NULL_VALUES;
-
Observe the result in the Results > Messages pane.
Expected Behavior
- The JSON output should appear as a single line or a single cell containing the entire JSON array, similar to behavior in SSMS 18.x / 19.x.
- The JSON should be valid, continuous, and ready to copy/export.
Actual Behavior
- In SSMS 22 Preview, the JSON output is split into multiple rows.
- Each row contains a fragment of the overall JSON text (for example, first 2033 characters per row).
- When copying results, JSON becomes invalid/incomplete unless manually concatenated.
Impact
- Makes it difficult to export or validate large JSON results.
- Breaks automation workflows that rely on copying query results directly from SSMS.
- Causes confusion for developers comparing results between SSMS 18/19 and SSMS 22 Preview.
Workarounds
-
Use:
DECLARE @json NVARCHAR(MAX); SELECT @json = ( SELECT ... FOR JSON PATH, INCLUDE_NULL_VALUES ); SELECT @json;
This returns JSON as one continuous NVARCHAR output.
-
Use older SSMS versions (18 or 19) where this issue doesn’t occur.
Screenshot
SSMS 22 Preview
SSMS older SSMS versions (18 or 19)
Additional Notes
- The issue appears to be related to SSMS result buffer limits or automatic output chunking introduced in SSMS 22 Preview.
- It is not related to SQL Server Engine, as the same query in other clients (Azure Data Studio, SSMS 19.x) returns continuous JSON.