I have table with data like this
Id | Name | Phone | OtherField
----+---------+--------+-----------
1 | ABC | 12344 | NULL
2 | XYZ | NULL | NULL
I want a SQL query to transform it like this
[
{
"ID":1,
"Name":"ABC",
"Phone":[
{"Home":"12344"}
],
"OtherFields":NULL
},
{
"ID":1,
"Name":"ABC",
"OtherFields":NULL
}
]
I know about INCLUDE_NULL_VALUES
it includes all the empty field.
I want to include all other fields except Phone.
I have edited my answer as you have changed your original request.
I don't believe you can have it both ways, keeping some NULLs and not others. The best way I can think of at the moment is to use
ISNULL
on columns you must keep.For example:
Returns