views:

63

answers:

2

So I've got a query in a JSP class that retrieves, basically, the entire contents of a table as a string using MS SQL's "FOR XML AUTO" feature.

I.e., select * from userdata for xml auto.

The problem is that the result is being truncated at around 2033 characters. There's no unusual character at that point or anything; the break occurs right in the middle of a plain-text attribute.

Is there some obvious thing that's likely causing this, like a limit parameter I need to increase somewhere?

Thanks.

+2  A: 

How are you reading in the result?

If you're using ResultSet.getString() I would first try replacing that with ResultSet.getBinaryInput() or getCharacterStream(), then make sure you read in the contents fully before closing the stream.

That's a much better way to do it, in case you end up with a giant data set you won't need to keep the whole thing in memory (especially if you use SAX to pick out the information you need, rather then building a DOM tree)

Chad Okere
+3  A: 

Here's the answer:

http://aspnetresources.com/blog/executescalar%5Ftruncates%5Fxml.aspx

Arthur Frankel
That was the problem. (It returns the XML in multiple rows of 2,033 characters each, instead of as a single row.) Thanks!
DanM