SQL Server 2005 XML Queries

Is there a way to apply schema to an xml column to input values ​​like Date, int, decimal, etc.? Also, when querying content using XPath, is there a way to check for the actual type and not its string value?

Should we even try this, is there any performance in doing raw string validation for these values, or should we be concerned about this approach?

+1


a source to share


1 answer


XML Schema for a SQL Server XML Column - yes, absolutely. What you need to do is create a collection of schemas (you can have multiple schemas in a collection)

CREATE XML SCHEMA COLLECTION MySchemaCollection
AS N'...(here comes your xml schema as a string).....'

      

and then when you define an XML column, you need to reference this XML schema assembly to bind the "XML column to this schema collection:"



CREATE TABLE YourTable
   (......(some fields),
    XmlField XML(DOCUMENT MySchemaCollection),
      .... (more fields) );

      

XPath case - not sure, but I don't think so - XML ​​really is nothing more than strings at the end, right?

Mark

+2


a source







All Articles