diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/DbColumnWrapper.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/DbColumnWrapper.cs
index 7574a7de..9e387f8c 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/DbColumnWrapper.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/DbColumnWrapper.cs
@@ -182,7 +182,12 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
///
/// Whether or not the column is XML
///
- public bool IsXml { get; private set; }
+ public bool IsXml { get; set; }
+
+ ///
+ /// Whether or not the column is JSON
+ ///
+ public bool IsJson { get; set; }
#endregion
diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/ResultSet.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/ResultSet.cs
index 58933532..ad392cf7 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/ResultSet.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/ResultSet.cs
@@ -24,6 +24,11 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
// xml is a special case so number of chars to store is usually greater than for other long types
private const int DefaultMaxXmlCharsToStore = 2097152; // 2 MB - QE default
+ // Column names of 'for xml' and 'for json' queries
+ private const string NameOfForXMLColumn = "XML_F52E2B61-18A1-11d1-B105-00805F49916B";
+ private const string NameOfForJSONColumn = "JSON_F52E2B61-18A1-11d1-B105-00805F49916B";
+
+
#endregion
#region Member Variables
@@ -192,6 +197,8 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
currentFileOffset += fileWriter.WriteRow(DataReader);
}
}
+ // Check if resultset is 'for xml/json'. If it is, set isJson/isXml value in column metadata
+ SingleColumnXmlJsonResultSet();
// Mark that result has been read
hasBeenRead = true;
@@ -225,5 +232,30 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
}
#endregion
+
+ #region Private Helper Methods
+
+ ///
+ /// If the result set represented by this class corresponds to a single XML
+ /// column that contains results of "for xml" query, set isXml = true
+ /// If the result set represented by this class corresponds to a single JSON
+ /// column that contains results of "for json" query, set isJson = true
+ ///
+ private void SingleColumnXmlJsonResultSet() {
+
+ if (Columns?.Length == 1)
+ {
+ if (Columns[0].ColumnName.Equals(NameOfForXMLColumn, StringComparison.Ordinal))
+ {
+ Columns[0].IsXml = true;
+ }
+ else if (Columns[0].ColumnName.Equals(NameOfForJSONColumn, StringComparison.Ordinal))
+ {
+ Columns[0].IsJson = true;
+ }
+ }
+ }
+
+ #endregion
}
}