[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

MSSQL validate an xml field agains an xsd file

Posted on 2012-08-15
2
Medium Priority
?
615 Views
Last Modified: 2012-09-06
Can someone show me how to validate a xml field against a
xsd file (or prefered an xsd in a field)
0
Comment
Question by:pucko73
2 Comments
 
LVL 30

Expert Comment

by:Rich Weissler
ID: 38300031
I'll start with an apology.  When it comes to xml, I'm still learning and haven't had occasion to use anything I've learned on the topic quite yet.  So, use that as salt to flavor the following:

I believe the XSD is imported/registered with SQL with the CREATE XML SCHEMA COLLECTION.  Once the XML schema is created, you can create TYPED XML objects, which are validated against the schema.  http://www.simple-talk.com/sql/learn-sql-server/working-with-the-xml-data-type-in-sql-server/ gets into the differences, and was a little easier to follow than anything I'd read previously.

I've tossed The Art of XSD: SQL Server XML Schema Collections on my Kindle, but haven't read it yet.
0
 
LVL 14

Accepted Solution

by:
nishant joshi earned 2000 total points
ID: 38301601
so you want to create typed xml column.
for that you have to first create xml schema collection.
CREATE XML SCHEMA COLLECTION mySC AS '
<schema xmlns="http://www.w3.org/2001/XMLSchema">
      <element name="root" type="string"/>
</schema>
'
GO
CREATE TABLE T (Col1 xml (mySC))
GO

Open in new window

Thanks.
Nishant
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question