Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

sp_xml_preparedocument - Return Value Expand / Collapse
Posted Tuesday, March 4, 2003 4:30 AM


Group: General Forum Members
Last Login: Thursday, June 4, 2015 8:12 AM
Points: 19, Visits: 13
According to the documentation sp_xml_preparedocument should return 0 (success) or >0 (failure).

The following Code fails to write my error record as it appears that a value is not being returned correctly.

Has anyone else encountered this problem ?

Suggestions welcome.



Declare @iDocError Int
Declare @Message Varchar(30)

EXECUTE @iDocError = sp_xml_preparedocument @iDoc OUTPUT, @XmlString
SELECT @iDocError
IF @iDocError <> 0 /*Can't Parse File*/
Set @Message = 'Problem Parsing File'
INSERT INTO ArcsXml (SourceFileName, OurStatus,RepairId)
Values(@SourceFileName ,@Messsage, -3)

Post #10342
Posted Friday, March 7, 2003 1:21 AM
UDP Broadcaster

UDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP Broadcaster

Group: General Forum Members
Last Login: Saturday, February 28, 2009 6:51 AM
Points: 1,489, Visits: 7
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.

Chris Hedgate @ Apptus Technologies (

Chris Hedgate
Contributor to the Best of SQL Server Central volumes
Post #55406
Posted Tuesday, April 15, 2014 11:14 AM


Group: General Forum Members
Last Login: Thursday, November 5, 2015 9:53 AM
Points: 100, Visits: 313
I've always used the other way around. When 0, then fail; when >0, then success. Is the SQL Server documentation incorrect?
Post #1561994
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse