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?

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.