Source: Format Query Results as JSON
The equivalent CLR function could receive the SQL query command as a textual parameter, and then use the DB context connection to execute a SqlCommand object with the input SQL Query, and then use DataTable / DataSet methods and collections to inspect the returned columns and data.
The equivalent CLR function could receive the SQL query command as a textual parameter, and then use the DB context connection to execute a SqlCommand object with the input SQL Query, and then use DataTable / DataSet methods and collections to inspect the returned columns and data.