简体   繁体   中英

SQL Server XML data type

I have a table in SQL Server 2005 SP4; in which one of the column will be of XML data type.

The problem is my XML can be of three different formats. (ie XML is not same but can be up to three different format) I want to use typed XML so

Question a) can I create XML schema collection that has XML schema for three different xml

I see a table in adventureworks database, Production.ProductModel in which catalogdescription column has three different schemas applied to it.

b) XML will be generated from ASP.net webform; should I construct XML in ASP.net or bring all form data in to SQL and construct XML there?

Thanks

For your first question - yes, you can define an XML schema collection which can - as the name "collection" implies - contain multiple XML schemata:

-- First create an XML schema collection.
CREATE XML SCHEMA COLLECTION MySchemaCollection 
  AS '<schema .......> ...... </schema>'

-- Modify the collection. 
ALTER XML SCHEMA COLLECTION MySchemaCollection 
  ADD '<schema ......>  ...... </schema>'

This way, you can define three separate schematas for your three types of XML data.

See the MSDN documatation Managing XML Schema Collections in SQL Server for more details.

As for your second question: I would guess that it probably is easier to just create it in your ASP.NET app and store it after it's been generated - otherwise you would have to first store the data in some kind of relational form (tables) and then generate XML from those.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM