My sample code is like this:
DECLARE @JsonText varchar(MAX) = '{
"Test": ""
}'
DECLARE @Name varchar(MAX) = JSON_VALUE(@JsonText, '$.Test') ;
IF (@Name IS NULL)
BEGIN
SELECT 'Null' AS Result
END
ELSE
BEGIN
SELECT 'Empty' AS Result
END
and I got an output:
Result
----------
Empty
My expected output is Null, I have tried with trim and then check string is empty then return null is working fine.
IF (@Result = '')
SET @Result = NULL;
But I am looking for any other alternative if available which returns null instead of empty.
NULL, then define the value asNullin your JSON.Nulland""are not the same value, just likeNULLand''aren't.