XML fields on SQL server

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 年 前
With my back office software, I read the NOPCommerce SQL tables. Product attributes are stored in XML-format, eg the OrderItem table has a column AttributesXML. However, I see that the datatype is a nvarchar(MAX) and not XML. This makes it difficult to analyze the data in an SQL-view using standard SQL functions.

Any reason why NOPCommerce did it like this? What would happen if I change the datatype into XML? Are there ways to analyse nvarchar(MAX) data? How do they do it in their core?

thx for help,

Philippe
6 年 前
I do not know the reasons behind the logic, but perhaps you can just cast or convert the data from nvarchar to xml in your SQL views or stored procedures for easier analyzing:
https://www.red-gate.com/simple-talk/sql/database-administration/converting-string-data-to-xml-and-xml-to-string-data/

https://docs.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql
6 年 前
Indeed, cast(column to XML). I will not alter the column's datatype.

thanks for the tip!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.