[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

MS SQL 2005 - compare @XML to schema collection

Posted on 2010-09-20
2
Medium Priority
?
547 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

656 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