XML Output is Truncated in SQL

后端 未结 8 1727
挽巷
挽巷 2020-12-09 03:44

I need to return my result set in XML and this works fine, but if the number of records are increased, my xml output is truncated here is my query



        
相关标签:
8条回答
  • 2020-12-09 04:02

    I've had the same problem with management studio and xml result sets. I've solved this by getting the output programatically with c#, with SqlDataReader.

    0 讨论(0)
  • 2020-12-09 04:07

    You can use SQL Management Studio for 2008 against a SQL Server 2005 database engine. If you do that, the defaults should be large enough, but in Tools -> Options -> Query Results -> SQL Server there is a Results to Grid and Results To Text node.

    Results to Grid allows you to control the maximum size for XML data explicitly, and the default maximum size is 2MB.

    If you don't have a license for SSMS 2008 you should be able to use the express edition for free here.

    0 讨论(0)
  • 2020-12-09 04:09

    The XML output you get in Query output window is not really intended for saving valid XML documents. You can get valid XML out of SQL Server when you capture it as a stream using ADO or SQLXML managed classes in .NET

    However you can limit the query output sizes by using In SQL Server Management Studio go to Tools >> Options >> Query Results >> SQL Server >> Results to Text >> Maximum number of characters displayed in each column

    0 讨论(0)
  • 2020-12-09 04:10

    This worked for me (SSMS 2012): Tools > Options > Query Results > SQL Server > Results to Grid: Maximum Characters Retried: XML data: Unlimited. Then I saved the results of the grid to a file.

    0 讨论(0)
  • 2020-12-09 04:12

    Try the following:

    Declare @xmldata xml
    set @xmldata = (select ... From test for xml...)
    select @xmldata as returnXml
    
    0 讨论(0)
  • 2020-12-09 04:14

    If your XML result set is still being truncated even after changing SSMS Options, use the SQLCMD utility with :XML ON option prior to running your XML statement. Direct your output to a file using the -o switch. SQLCMD is a command line utility that is very simple to use. See http://msdn.microsoft.com/en-us/library/ms162773.aspx.

    0 讨论(0)
提交回复
热议问题