Solved

MS SQL 2005 - compare @XML to schema collection

Posted on 2010-09-20
2
534 Views
Last Modified: 2012-05-10
Hi Expert,

I would like to create a SQL store procedure that insert XML data in a XML column.

But the table will contain many different type of XML (Many different Schema).

How Can I used the Schema collection to validate the XML data before inserting it?

Something like this:
 
create proc XML_INS
	@xml_data xml
	, @vchSchemaName varchar(100)
as 


if @xml_data is conform to SCHEMA COLLECTION @vchSchemaName 
begin 
 -- insert 
end
else 
begin 
 -- raiseerror()
end

Open in new window

0
Comment
Question by:Cboudroz
2 Comments
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33717480
0
 
LVL 7

Accepted Solution

by:
Cboudroz earned 0 total points
ID: 33747628
Thanks for the links,

I find out that the best way was to Create temp table whit XML column link to a XML schema and do a insert inside of a TRY CATCH Block, if error schema is not valid.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MSSQL join different row from other table 14 65
SQL Server Sum Over Multiple Tables 20 31
how to make geography query faster?  SQL 7 42
Need help with a query 14 35
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

740 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