SQL函数在查询和异常处理中的应用

SQL函数在查询和异常处理中的应用,sql,function,clr,.net-assembly,Sql,Function,Clr,.net Assembly,在查询中,我使用了一个SQL函数(调用.NET函数进行xml转换) 当函数ApplyXMLTransform遇到异常时,整个查询将启动。。。有没有办法防止异常破坏整个记录集(在查询方面,我意识到我可以修改函数来处理托管代码中的异常) 异常本身也是一个神秘的故事,因为当我查询罪魁祸首记录时,我没有看到构成异常的无效字符等。。。但那是另一罐虫子。。。以下是错误: Msg 6522, Level 16, State 1, Line 3 A .NET Framework error occurred d

在查询中,我使用了一个SQL函数(调用.NET函数进行xml转换)

当函数ApplyXMLTransform遇到异常时,整个查询将启动。。。有没有办法防止异常破坏整个记录集(在查询方面,我意识到我可以修改函数来处理托管代码中的异常)

异常本身也是一个神秘的故事,因为当我查询罪魁祸首记录时,我没有看到构成异常的无效字符等。。。但那是另一罐虫子。。。以下是错误:

Msg 6522, Level 16, State 1, Line 3
A .NET Framework error occurred during execution of user-defined routine or aggregate "ApplyXsltTransform": 
System.Xml.XmlException: Invalid character in the given encoding. Line 21, position 417.
System.Xml.XmlException: 
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.InvalidCharRecovery(Int32& bytesCount, Int32& charsCount)
   at System.Xml.XmlTextReaderImpl.GetChars(Int32 maxCharsCount)
   at System.Xml.XmlTextReaderImpl.ReadData()
   at System.Xml.XmlTextReaderImpl.ParseText(Int32& startPos, Int32& endPos, Int32& outOrChars)
   at System.Xml.XmlTextReaderImpl.ParseText()
   at System.Xml.XmlTextReaderImpl.ParseElementContent()
   at System.Xml.XmlWriter.WriteNode(XmlReader reader, Boolean defattr)
   at System.Data.SqlTypes.SqlXml.CreateMemoryStreamFromXmlReader(XmlReader reader)
   at System.Data.SqlTypes.SqlXml..ctor(XmlReader value)
   at NF.Sql.Extensions.XSLTTransform.Transform(SqlXml inputDataXML, SqlXml inputTransformXML)
.

捕获函数中的异常,并返回一个漂亮的小字符串“Error accurrent”或其他内容。谢谢,这正是我正在做的,并返回异常详细信息。我想真的没有办法通过查询来处理它。。。
Msg 6522, Level 16, State 1, Line 3
A .NET Framework error occurred during execution of user-defined routine or aggregate "ApplyXsltTransform": 
System.Xml.XmlException: Invalid character in the given encoding. Line 21, position 417.
System.Xml.XmlException: 
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.InvalidCharRecovery(Int32& bytesCount, Int32& charsCount)
   at System.Xml.XmlTextReaderImpl.GetChars(Int32 maxCharsCount)
   at System.Xml.XmlTextReaderImpl.ReadData()
   at System.Xml.XmlTextReaderImpl.ParseText(Int32& startPos, Int32& endPos, Int32& outOrChars)
   at System.Xml.XmlTextReaderImpl.ParseText()
   at System.Xml.XmlTextReaderImpl.ParseElementContent()
   at System.Xml.XmlWriter.WriteNode(XmlReader reader, Boolean defattr)
   at System.Data.SqlTypes.SqlXml.CreateMemoryStreamFromXmlReader(XmlReader reader)
   at System.Data.SqlTypes.SqlXml..ctor(XmlReader value)
   at NF.Sql.Extensions.XSLTTransform.Transform(SqlXml inputDataXML, SqlXml inputTransformXML)
.