views:

53

answers:

1

Is there a way to apply a schema to an xml column to type values such as Date, int, decimal, etc? Also, when querying the contents with XPath is there a way to do check against the actual type and not its string value?

Should we even try this, is there a performance hit with doing raw string checks for these values, or should we even be concerned with this approach?

+2  A: 

XML schema for SQL Server XML column - yes, absolutely. What you'll need to do is create a schema collection (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 the XML column, you need to reference that XML schema collection to bind" the XML column to that schema collection:

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

The XPath thing - not sure, but I don't think so - XML really is nothing but strings in the end, right?

Marc

marc_s