I have got two queries, but I just want one result:
1 Query, give me all the data of the column
SELECT * FROM dbo.Notificacion
FOR JSON PATH, ROOT('notification')
2 Query give me all the column names
SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'notificacion' ORDER BY ORDINAL_POSITION
FOR JSON PATH, ROOT('COLUMN_NAME')
This way, I can make the view of the application more dynamic.
I want JSON something like this:
{
"COLUMN_NAME": [
{
"COLUMN_NAME": "ID"
},
{
"COLUMN_NAME": "Active"
},
{
"COLUMN_NAME": "date"
},
{
"COLUMN_NAME": "dateUpdate"
}
],
"notification": [
{
"ID": 1103,
"Active": 1016,
"date": 0,
"dateUpdate": 0
},
{
"ID": 1103,
"Active": 1016,
"date": 0,
"dateUpdate": 0
},
{
"ID": 1103,
"Active": 1016,
"date": 0,
"dateUpdate": 0
}
]
}