Solved

MS SQL 2005 - compare @XML to schema collection

Posted on 2010-09-20
2
526 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now