Andy, why should it record an error? If all goes well, as it should, the code would just go past the if-statement. If the xml-string is not valid then parsing will create an error and your code should actually stop running. I am not 100% sure, but I the only way you could run sp_xml_preparedocument without encountering an error but still getting a non-zero return value is if there is not enough memory for the operation or something like that.