Solved

MS SQL 2005 - compare @XML to schema collection

Posted on 2010-09-20
2
520 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
Comment Utility
0
 
LVL 7

Accepted Solution

by:
Cboudroz earned 0 total points
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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.

763 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

9 Experts available now in Live!

Get 1:1 Help Now