Exporting to XML error in SQL server 2000

Posted on 2006-05-03
Last Modified: 2008-01-09
I have written these SP to export:


select 1 as Tag, NULL as Parent, trans_date as [Item!1!trans_date], system_qty as [Item!1!system_qty],
part_name as [Item!1!part_name]
from fastpic.FP_INVTRANS as A
Where trans_date = (select max(trans_date) from fastpic.fp_invtrans i
where a.part_name = i.part_name)and trans_type <> 'ORDER COMPLETE'
order by trans_date desc
for xml explicit


DECLARE @cmd varchar(200)
set @cmd = 'bcp "EXEC fastpic2.dbo.CREATEXML" queryout c:\parts.xml -S. -Usa -P -c -r -t'
exec master ..xp_cmdshell @cmd  

I get a fileexported but it is not a complete file. I get this error in the output window:

Starting copy...
SQLState = S1000, NativeError = 0
Error = [Microsoft][SQL Native Client][SQL Server]Warning: Server data (2033 bytes) exceeds host-file field length (0 bytes) for field (1).  Use prefix length, termination string, or a larger host-file field size.  Truncation cannot occur for BCP output files.

anybody has any ideas? does this error mean that my fields are too large? that's not possible.


Question by:lytung818

    Author Comment

    I also read that using this method there is a limit in size...i was thinking about trying this method

    sp_makewebtask @outputfile = 'c:\myxmlfile.xml',
    @query = exec runxml,
    @templatefile = 'c:\scripts\template1.tpl'

    but it didn't work .How do i use a store procedure instead of a select statement in the @query?

    thanks a lot.
    LVL 75

    Expert Comment

    by:Anthony Perkins
    >>anybody has any ideas? does this error mean that my fields are too large?<<
    I suspect that BCP is seeing it as one field and so the answer is yes.  I suggest you use a front-end app to get the Xml document using something like VB or .NET

    Author Comment

    thanks but i solved the problem ...

    i did this

    sp_makewebtask @outputfile = 'c:\allParts.xml',
    @query ='select trans_date, system_qty, part_name
    from fastpic.FP_INVTRANS as A Where trans_date = (select max(trans_date) from fastpic.fp_invtrans i
    where a.part_name = i.part_name) and trans_type <> ''ORDER COMPLETE''
    order by trans_date  desc for xml auto',
    @templatefile = 'c:\scripts\template1.tpl'
    LVL 75

    Expert Comment

    by:Anthony Perkins
    >>thanks but i solved the problem ...<<
    Great!  Please close the question.  See here:
    I answered my question myself. What do I do?

    Accepted Solution

    Closed, 250 points refunded.
    The Experts Exchange
    Community Support Moderator of all Ages

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
    Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now