JSON Support for SQL Server

Documentation › JsonNVarChar Custom Length

JsonNVarChar Custom Length

Create custom length JsonNVarChar functions using the installer to suit your specific needs

Using the installer, you can add custom-length JsonNVarChar functions. Just add a comma-separated list of the lengths you want in the text box, as shown in this image:

Add custom-length JsonNVarChar functions via installer

In the example image, we will get three new functions - JsonNVarChar5(), JsonNVarChar20() and JsonNVarChar255().

Important Note:

There is no equivalent custom-length functionality for the JSON data type, due to the way that CLR data types work. However, for the JSON data type, you can still use the QueryNVarChar() function and specify the length that you require.

Example

declare @testData nvarchar(1000) set @testData = '{ "Numbers": "1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 " }' select dbo.JsonNVarChar5(@testData, 'Numbers') as [Test 5 Chars], dbo.JsonNVarChar20(@testData, 'Numbers') as [Test 20 Chars], dbo.JsonNVarChar255(@testData, 'Numbers') as [Test 255 Chars]

Results

Test 5 Chars Test 20 Chars Test 255 Chars
1 3 5 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9