Subscribe To

Subscribe to SQL Server and XML by Email
Labels

Tuesday, March 17, 2009

Practical SQL Server XML: Part Three

Moved to http://beyondrelational.com/blogs/jacob/archive/2009/03/17/practical-sql-server-xml-part-three.aspx

2 comments:

  1. Great article! What if there were multiple errors when validating the XML document and I wanted to store the error code, attribute and value in a table so I can create an error report?

    ReplyDelete
  2. Hi Suhail,
    You can put your code into a TRY CATCH block and capture the ERROR_MESSAGE() which can then be inserted to a log table.

    For example:

    BEGIN TRY
    DECLARE @x XML(PersonSchema)
    SELECT @x = '
    [Person]
    [PersonType]SC[/PersonType]
    [/Person]'
    END TRY
    BEGIN CATCH
    SELECT ERROR_MESSAGE()
    END CATCH

    Note: Please replace [] with XML tags

    ReplyDelete

About Me
Jacob Sebastian
Tutorials
* XQuery Tutorials
My Links
SQL Server White Papers
SQL Server 2008
My Articles
XML Workshop RSS Feed
Contact me
Readers
Free Hit Counter
Web Site Hit Counters
SQL Server Bloggers
Blog Directories
blogarama - the blog directory Programming Blogs - BlogCatalog Blog Directory
 
Copyright Jacob Sebastian