﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 7,2000 / T-SQL  / RaiseError in TRY/Catch block after XML Schema Collection Validation. / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 21 May 2013 01:17:02 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: RaiseError in TRY/Catch block after XML Schema Collection Validation.</title><link>http://www.sqlservercentral.com/Forums/Topic690049-8-1.aspx</link><description>Matt,I tried by putting the XML schema validation within a nested Try/Catch in the proc and now it's able to capture the LocalError passsed in.Thanks for you feedback.</description><pubDate>Fri, 03 Apr 2009 16:57:04 GMT</pubDate><dc:creator>bdba</dc:creator></item><item><title>RE: RaiseError in TRY/Catch block after XML Schema Collection Validation.</title><link>http://www.sqlservercentral.com/Forums/Topic690049-8-1.aspx</link><description>Are you spelling the "raise error" correctly? It's "Raiserror", not "RaiseError".</description><pubDate>Fri, 03 Apr 2009 10:20:06 GMT</pubDate><dc:creator>dmbaker</dc:creator></item><item><title>RaiseError in TRY/Catch block after XML Schema Collection Validation.</title><link>http://www.sqlservercentral.com/Forums/Topic690049-8-1.aspx</link><description>I am trying to Raise an error using RAISEERROR function in sql when the XML schema validation fails.I am doing this inside a store proc. I am declaring the XML doc binding it to it's XSD schema in the TRY block and if validation fails, raise a user define error number by using RAISEERROR function in the catch block. However, somehow i am not able to do this and sql return it's own error the moment it executes that line of code. So using Employee example here, I am doing something like this.CREATE PROC ImportEmployeeInfo@EmployeeXML as XMLASBEGINBEGIN TRYDECLARE @EmpXML AS XML(EmployeeSchema) --declaring a local XML variable and binding it to its XSD Schema CollectionDECLARE @LocalErrorSET @EmpXML = @EmployeeXML -- here I am setting the @EmpXML to @EmployeeXML variable passed inIF @@error&amp;lt;&amp;gt;0 --if the @EmployeeXML failed the XSD validation, i beileve there would be an error right however this line never gets executedBEGINSET @LocalError = 50001 --user defined errorRaiseError(' The input parameter @EmployeeXML is not valid', 16, 1)END--The XML shredding and import into table goes hereEND TRYBEGIN CATCH--I have another another user defined errorhandler proc here which will take the above @LocalError --as input parameter and raise a detailed errorEND CATCHEND --End of Proc</description><pubDate>Fri, 03 Apr 2009 09:40:18 GMT</pubDate><dc:creator>bdba</dc:creator></item></channel></rss>