none
bcp xml format file RRS feed

  • Question

  • in the current application we are currently using a non xml format file like below.

    7.0
    15
    1       SQLCHAR       0       30      ""                        1     ABC
    2       SQLCHAR       0       12      ""                        2     DEF
    3       SQLCHAR       0       60      ""                        0     FILLER
    4       SQLCHAR       0       39      ""                        0     FILLER
    5       SQLCHAR       0       5       ""                        0     FILLER
    6       SQLCHAR       0       7       ""                        3     XYZ
    7       SQLCHAR       0       10      ""                        0     FILLER
    8       SQLCHAR       0       10      ""                        0     FILLER
    9       SQLCHAR       0       4       ""                        11    PRQ
    10      SQLCHAR       0       4       ""                        0     FILLER
    11      SQLCHAR       0       25      ""                        44   LMN
    12      SQLCHAR       0       4       ""                        58    CO
    13      SQLCHAR       0       3       ""                        59    APPL
    14      SQLCHAR       0       20      ""                        60    ACCT
    15      SQLCHAR       0       10      "\r\n"                    61    PD_C

     

    I want to convert this non xml format file to  xml format file.  I am not sure how to specify the filler and  column terminator as "".  Any help would be greatly appreciated. Thank you.

    Saturday, December 11, 2010 9:22 PM

Answers

  • Use thje format and -x options from bcp to create an XML format file.  Quote from: http://msdn.microsoft.com/en-us/library/ms191516.aspx

     "To use a bcp command to create a format file, specify the format argument and use nul instead of a data-file path. The format option always requires the -f option, and to create an XML format file, you must also specify the -x option, such as:

    bcp table_or_view format nul -f format_file_name -x "

     

    • Marked as answer by Ai-hua Qiu Monday, December 20, 2010 9:39 AM
    Sunday, December 12, 2010 5:19 PM
    Answerer