How can I combine several columns (of varying types, e.g. int, datetime, nvarchar) as a single JSON-formatted expression in a select query? For example, I have columns col1, col2 and want the query to return a single column where each row like this:
{col1: val1, col2: val2}
Can I use FOR JSON? I'm using SQL Server 2017, but the database I'm querying is 2008 (100) compatibility mode.
Apologies if this has been asked before, but I couldn't find anything that quite matches, although it seems like a very simple question.