开发者

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. (i.e. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜