正确的 BCP 语法

发布于 2024-09-16 10:02:47 字数 15892 浏览 6 评论 0原文

我是 BCP 的第一次用户。我有一个 XML 文件,需要将其导入到 SQL Server 中的新表中。这是使用 SQL Server 2008 和 BCP 版本 10.50.16。我通读了文档,但收到了 370,000 个错误! (这是一个非常大的文件)。当我打开错误日志时,我只看到一堆问号。

关于此 XML 文件:它确实使用换行符来划分行,但是,它使用空格字符来分隔字段。所以我不确定这是否是导致它失败的原因。失败消息是:

BCP 复制失败我希望它更具描述性。有没有办法获得更详细的错误消息?

否则,这是我的命令:

d:\SQL Tables\data>bcp Development.dbo.wbl_zSkywardEnrollment2 in zSkywardEnroll
ment.xml -fSE_format.fmt -m50 -eseErrorLog -b100 -t0x20 -T -F107

所有这些文件都位于同一目录中。我知道它说要指定完整文件路径,但由于它们都在同一个目录中,而且我还看到了另一个示例,其中他们没有指定目录,我认为这就足够了。

我也尝试过在没有格式文件的情况下以交互方式执行此操作,但出现相同的错误。

这是我的格式文件:

10.0
32
1       SQLINT              0       4       " "    1     SCHOOL_YEAR                                ""
2       SQLNCHAR            2       20      " "    2     ENTITY_ID                                  SQL_Latin1_General_CP1_CI_AS
3       SQLINT              0       4       " "    3     TERM_NBR                                   ""
4       SQLINT              1       4       " "    4     SCHD_HST_GRAD_YEAR                         ""
5       SQLNCHAR            2       60      " "    5     OTHER_ID                                   SQL_Latin1_General_CP1_CI_AS
6       SQLNUMERIC          1       19      " "    6     GRAD_YR                                    ""
7       SQLNCHAR            2       120     " "    7     LAST_NAME                                  SQL_Latin1_General_CP1_CI_AS
8       SQLNCHAR            2       60      " "    8     FIRST_NAME                                 SQL_Latin1_General_CP1_CI_AS
9       SQLNCHAR            2       60      " "    9     MIDDLE_NAME                                SQL_Latin1_General_CP1_CI_AS
10      SQLDATETIME         1       8       " "    10    BIRTHDATE                                  ""
11      SQLNCHAR            2       4       " "    11    GENDER                                     SQL_Latin1_General_CP1_CI_AS
12      SQLNCHAR            2       20      " "    12    RACE_CODE                                  SQL_Latin1_General_CP1_CI_AS
13      SQLNCHAR            2       40      " "    13    DISTRICT_CODE                              SQL_Latin1_General_CP1_CI_AS
14      SQLBIT              1       1       " "    14    X_SPECIAL_EDUCATION                        ""
15      SQLBIT              1       1       " "    15    X_GIFTED_TALENTED                          ""
16      SQLBIT              1       1       " "    16    X_SECTION_504                              ""
17      SQLBIT              1       1       " "    17    X_MIGRANT                                  ""
18      SQLBIT              1       1       " "    18    X_IEP                                      ""
19      SQLBIT              1       1       " "    19    X_IEP_ACCOM                                ""
20      SQLBIT              1       1       " "    20    X_ESL                                      ""
21      SQLNCHAR            2       4       " "    21    STUDENT_STATUS                             SQL_Latin1_General_CP1_CI_AS
22      SQLINT              0       4       " "    22    STUDENT_ID                                 ""
23      SQLINT              1       4       " "    23    ENG_PROF                                   ""
24      SQLNCHAR            2       60      " "    24    ALPHAKEY                                   SQL_Latin1_General_CP1_CI_AS
25      SQLNCHAR            2       20      " "    25    SCHOOL_ID                                  SQL_Latin1_General_CP1_CI_AS
26      SQLNUMERIC          1       19      " "    26    MN_EDE_NBR                                 ""
27      SQLNCHAR            2       20      " "    27    LANGUAGE_CODE                              SQL_Latin1_General_CP1_CI_AS
28      SQLINT              1       4       " "    28    ADVISOR                                    ""
29      SQLBIT              1       1       " "    29    MN_LIMITED_ENGLISH                         ""
30      SQLNCHAR            2       20      " "    30    TYPE_STUDENT_ID                            SQL_Latin1_General_CP1_CI_AS
31      SQLNCHAR            2       20      " "    31    CY_TEAM_SCHD_ID                            SQL_Latin1_General_CP1_CI_AS
32      SQLNCHAR            2       20      " "    32    HOMEROOM_NUMBER                            SQL_Latin1_General_CP1_CI_AS

这是我的 SQL 表:

CREATE TABLE [dbo].[wbl_zSkywardEnrollment2](
    [SCHOOL_YEAR] [int] NOT NULL,
    [ENTITY_ID] [nvarchar](10) NOT NULL,
    [TERM_NBR] [int] NOT NULL,
    [SCHD_HST_GRAD_YEAR] [int] NULL,
    [OTHER_ID] [nvarchar](30) NULL,
    [GRAD_YR] numeric(19,0) NULL,
    [LAST_NAME] [nvarchar](60) NOT NULL,
    [FIRST_NAME] [nvarchar](30) NULL,
    [MIDDLE_NAME] [nvarchar](30) NULL,
    [BIRTHDATE] datetime NULL,
    [GENDER] [nvarchar](2) NULL,
    [RACE_CODE] [nvarchar](10) NULL,
    [DISTRICT_CODE] [nvarchar](20) NULL,
    [X_SPECIAL_EDUCATION] bit NULL,
    [X_GIFTED_TALENTED] bit NULL,
    [X_SECTION_504] bit NULL,
    [X_MIGRANT] bit NULL,
    [X_IEP] bit NULL,
    [X_IEP_ACCOM] bit NULL,
    [X_ESL] bit NULL,
    [STUDENT_STATUS] [nvarchar](2) NULL,
    [STUDENT_ID] [int] NOT NULL,
    [ENG_PROF] [int] NULL,
    [ALPHAKEY] [nvarchar](30) NOT NULL,
    [SCHOOL_ID] [nvarchar](10) NULL,
    [MN_EDE_NBR] [numeric](19, 0) NULL,
    [LANGUAGE_CODE] [nvarchar](10) NULL,
    [ADVISOR] [int] NULL,
    [MN_LIMITED_ENGLISH] bit NULL,
    [TYPE_STUDENT_ID] [nvarchar](10) NULL,
    [CY_TEAM_SCHD_ID] [nvarchar](10) NULL,
    [HOMEROOM_NUMBER] [nvarchar](10) NOT NULL
) ON [PRIMARY]

我已经从第 1 行开始尝试过此操作。我很好奇 BCP 应该从哪一行开始?此 XML 的第 1 行以 Schema 和 ElementType 信息开头。但第 107 行是 rs:data 部分开始的地方。

此 XML 文件的第一部分:

<xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'

    xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'

    xmlns:rs='urn:schemas-microsoft-com:rowset'

    xmlns:z='#RowsetSchema'>

<s:Schema id='RowsetSchema'>

    <s:ElementType name='row' content='eltOnly'>

        <s:AttributeType name='c0' rs:name='SCHOOL_YEAR' rs:number='1'>

            <s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true' rs:maybenull='false'/>

        </s:AttributeType>

        <s:AttributeType name='c1' rs:name='ENTITY_ID' rs:number='2'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='10' rs:maybenull='false'/>

        </s:AttributeType>

        <s:AttributeType name='c2' rs:name='TERM_NBR' rs:number='3'>

            <s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true' rs:maybenull='false'/>

        </s:AttributeType>

        <s:AttributeType name='c3' rs:name='SCHD_HST_GRAD_YEAR' rs:number='4' rs:nullable='true'>

            <s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true'/>

        </s:AttributeType>

        <s:AttributeType name='c4' rs:name='OTHER_ID' rs:number='5' rs:nullable='true'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='24'/>

        </s:AttributeType>

        <s:AttributeType name='c5' rs:name='GRAD_YR' rs:number='6' rs:nullable='true'>

            <s:datatype dt:type='number' rs:dbtype='numeric' dt:maxLength='19' rs:scale='0' rs:precision='15' rs:fixedlength='true'/>

        </s:AttributeType>

        <s:AttributeType name='c6' rs:name='LAST_NAME' rs:number='7'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='60' rs:maybenull='false'/>

        </s:AttributeType>

        <s:AttributeType name='c7' rs:name='FIRST_NAME' rs:number='8' rs:nullable='true'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='30'/>

        </s:AttributeType>

        <s:AttributeType name='c8' rs:name='MIDDLE_NAME' rs:number='9' rs:nullable='true'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='30'/>

        </s:AttributeType>

        <s:AttributeType name='BIRTHDATE' rs:name='BIRTHDATE' rs:number='10' rs:nullable='true' rs:write='true'>

            <s:datatype dt:type='date' dt:maxLength='6' rs:fixedlength='true'/>

        </s:AttributeType>

        <s:AttributeType name='GENDER' rs:name='GENDER' rs:number='11' rs:nullable='true' rs:write='true'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='2'/>

        </s:AttributeType>

        <s:AttributeType name='c11' rs:name='RACE_CODE' rs:number='12' rs:nullable='true'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='6'/>

        </s:AttributeType>

        <s:AttributeType name='c12' rs:name='DISTRICT_CODE' rs:number='13' rs:nullable='true'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='14'/>

        </s:AttributeType>

        <s:AttributeType name='c13' rs:name='X_SPECIAL_EDUCATION' rs:number='14' rs:nullable='true'>

            <s:datatype dt:type='boolean' dt:maxLength='2' rs:fixedlength='true'/>

        </s:AttributeType>

        <s:AttributeType name='c14' rs:name='X_GIFTED_TALENTED' rs:number='15' rs:nullable='true'>

            <s:datatype dt:type='boolean' dt:maxLength='2' rs:fixedlength='true'/>

        </s:AttributeType>

        <s:AttributeType name='c15' rs:name='X_SECTION_504' rs:number='16' rs:nullable='true'>

            <s:datatype dt:type='boolean' dt:maxLength='2' rs:fixedlength='true'/>

        </s:AttributeType>

        <s:AttributeType name='c16' rs:name='X_MIGRANT' rs:number='17' rs:nullable='true'>

            <s:datatype dt:type='boolean' dt:maxLength='2' rs:fixedlength='true'/>

        </s:AttributeType>

        <s:AttributeType name='c17' rs:name='X_IEP' rs:number='18' rs:nullable='true'>

            <s:datatype dt:type='boolean' dt:maxLength='2' rs:fixedlength='true'/>

        </s:AttributeType>

        <s:AttributeType name='c18' rs:name='X_IEP_ACCOM' rs:number='19' rs:nullable='true'>

            <s:datatype dt:type='boolean' dt:maxLength='2' rs:fixedlength='true'/>

        </s:AttributeType>

        <s:AttributeType name='c19' rs:name='X_ESL' rs:number='20' rs:nullable='true'>

            <s:datatype dt:type='boolean' dt:maxLength='2' rs:fixedlength='true'/>

        </s:AttributeType>

        <s:AttributeType name='c20' rs:name='STUDENT_STATUS' rs:number='21' rs:nullable='true'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='2'/>

        </s:AttributeType>

        <s:AttributeType name='c21' rs:name='STUDENT_ID' rs:number='22'>

            <s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true' rs:maybenull='false'/>

        </s:AttributeType>

        <s:AttributeType name='c22' rs:name='ENGL_PROF' rs:number='23' rs:nullable='true'>

            <s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true'/>

        </s:AttributeType>

        <s:AttributeType name='ALPHAKEY' rs:name='ALPHAKEY' rs:number='24' rs:write='true'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='22' rs:maybenull='false'/>

        </s:AttributeType>

        <s:AttributeType name='c24' rs:name='SCHOOL_ID' rs:number='25'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='10' rs:maybenull='false'/>

        </s:AttributeType>

        <s:AttributeType name='c25' rs:name='MN_EDE_NBR' rs:number='26' rs:nullable='true'>

            <s:datatype dt:type='number' rs:dbtype='numeric' dt:maxLength='19' rs:scale='0' rs:precision='15' rs:fixedlength='true'/>

        </s:AttributeType>

        <s:AttributeType name='c26' rs:name='LANGUAGE_CODE' rs:number='27' rs:nullable='true'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='6'/>

        </s:AttributeType>

        <s:AttributeType name='c27' rs:name='ADVISOR' rs:number='28' rs:nullable='true' rs:write='true'>

            <s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true'/>

        </s:AttributeType>

        <s:AttributeType name='c28' rs:name='MN_LIMITED_ENGLISH' rs:number='29' rs:nullable='true'>

            <s:datatype dt:type='boolean' dt:maxLength='2' rs:fixedlength='true'/>

        </s:AttributeType>

        <s:AttributeType name='c29' rs:name='TYPE_STUDENT_ID' rs:number='30' rs:nullable='true'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='6'/>

        </s:AttributeType>

        <s:AttributeType name='c30' rs:name='CY_TEAM_SCHD_ID' rs:number='31' rs:nullable='true'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='6'/>

        </s:AttributeType>

        <s:AttributeType name='c31' rs:name='HOMEROOM_NUMBER' rs:number='32'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='10' rs:maybenull='false'/>

        </s:AttributeType>

        <s:extends type='rs:rowbase'/>

    </s:ElementType>

</s:Schema>

<rs:data>

    <z:row c0='2004' c1='057' c2='0' c3='2010' c4='671590' c5='2010' c6='AANENSON' c7='SHELLI' c8='A' BIRTHDATE='1992-07-01'

         GENDER='F' c11='5' c12='' c13='False' c14='True' c15='False' c16='False' c17='False' c18='False' c19='False'

         c20='I' c21='12' c22='7' ALPHAKEY='AANENSHE000' c24='057' c25='624000671590' c26='011' ADVISOR='0' c28='False'

         c29='R' c30='' c31=''/>

    <z:row c0='2004' c1='057' c2='0' c3='2010' c4='671590' c5='2010' c6='AANENSON' c7='SHELLI' c8='A' BIRTHDATE='1992-07-01'

         GENDER='F' c11='5' c12='' c13='False' c14='True' c15='False' c16='False' c17='False' c18='False' c19='False'

         c20='I' c21='12' c22='7' ALPHAKEY='AANENSHE000' c24='057' c25='624000671590' c26='011' ADVISOR='0' c28='False'

         c29='R' c30='' c31=''/>

    <z:row c0='2004' c1='057' c2='0' c3='2010' c4='671590' c5='2010' c6='AANENSON' c7='SHELLI' c8='A' BIRTHDATE='1992-07-01'

         GENDER='F' c11='5' c12='' c13='False' c14='True' c15='False' c16='False' c17='False' c18='False' c19='False'

         c20='I' c21='12' c22='7' ALPHAKEY='AANENSHE000' c24='057' c25='624000671590' c26='011' ADVISOR='0' c28='False'

         c29='R' c30='' c31=''/>

    <z:row c0='2004' c1='057' c2='0' c3='2010' c4='671590' c5='2010' c6='AANENSON' c7='SHELLI' c8='A' BIRTHDATE='1992-07-01'

         GENDER='F' c11='5' c12='' c13='False' c14='True' c15='False' c16='False' c17='False' c18='False' c19='False'

         c20='I' c21='12' c22='7' ALPHAKEY='AANENSHE000' c24='057' c25='624000671590' c26='011' ADVISOR='0' c28='False'

         c29='R' c30='' c31=''/>

    <z:row c0='2004' c1='057' c2='0' c3='2010' c4='671590' c5='2010' c6='AANENSON' c7='SHELLI' c8='A' BIRTHDATE='1992-07-01'

         GENDER='F' c11='5' c12='' c13='False' c14='True' c15='False' c16='False' c17='False' c18='False' c19='False'

         c20='I' c21='12' c22='7' ALPHAKEY='AANENSHE000' c24='057' c25='624000671590' c26='011' ADVISOR='0' c28='False'

         c29='R' c30='' c31=''/>

    <z:row c0='2004' c1='057' c2='0' c3='2010' c4='671590' c5='2010' c6='AANENSON' c7='SHELLI' c8='A' BIRTHDATE='1992-07-01'

         GENDER='F' c11='5' c12='' c13='False' c14='True' c15='False' c16='False' c17='False' c18='False' c19='False'

         c20='I' c21='12' c22='7' ALPHAKEY='AANENSHE000' c24='057' c25='624000671590' c26='011' ADVISOR='0' c28='False'

         c29='R' c30='' c31=''/>

I am a first time BCP user. I have an XML file that I need to import into a new table in SQL Server. This is using SQL Server 2008 and BCP version 10.50.16. I read through the documentation but I get 370,000 errors! (This is a very large file). When I open the error log, I just see a bunch of question marks.

About this XML file: it does use a new line to delineate rows, however, it uses the space character to separate fields. So I'm not sure if that is what causes it to fail. The failure message is:

BCP copy in failedI wish it were more descriptive. Is there a way to get a more detailed error message?

Otherwise, here is my command:

d:\SQL Tables\data>bcp Development.dbo.wbl_zSkywardEnrollment2 in zSkywardEnroll
ment.xml -fSE_format.fmt -m50 -eseErrorLog -b100 -t0x20 -T -F107

All of these files are in this same directory. I know it says to specify full file path, but since they're all in this same directory and also I saw another example where they didn't specify directories I thought this would suffice.

I have tried this without the format file also, doing it interactively but get same errors.

This is my format file:

10.0
32
1       SQLINT              0       4       " "    1     SCHOOL_YEAR                                ""
2       SQLNCHAR            2       20      " "    2     ENTITY_ID                                  SQL_Latin1_General_CP1_CI_AS
3       SQLINT              0       4       " "    3     TERM_NBR                                   ""
4       SQLINT              1       4       " "    4     SCHD_HST_GRAD_YEAR                         ""
5       SQLNCHAR            2       60      " "    5     OTHER_ID                                   SQL_Latin1_General_CP1_CI_AS
6       SQLNUMERIC          1       19      " "    6     GRAD_YR                                    ""
7       SQLNCHAR            2       120     " "    7     LAST_NAME                                  SQL_Latin1_General_CP1_CI_AS
8       SQLNCHAR            2       60      " "    8     FIRST_NAME                                 SQL_Latin1_General_CP1_CI_AS
9       SQLNCHAR            2       60      " "    9     MIDDLE_NAME                                SQL_Latin1_General_CP1_CI_AS
10      SQLDATETIME         1       8       " "    10    BIRTHDATE                                  ""
11      SQLNCHAR            2       4       " "    11    GENDER                                     SQL_Latin1_General_CP1_CI_AS
12      SQLNCHAR            2       20      " "    12    RACE_CODE                                  SQL_Latin1_General_CP1_CI_AS
13      SQLNCHAR            2       40      " "    13    DISTRICT_CODE                              SQL_Latin1_General_CP1_CI_AS
14      SQLBIT              1       1       " "    14    X_SPECIAL_EDUCATION                        ""
15      SQLBIT              1       1       " "    15    X_GIFTED_TALENTED                          ""
16      SQLBIT              1       1       " "    16    X_SECTION_504                              ""
17      SQLBIT              1       1       " "    17    X_MIGRANT                                  ""
18      SQLBIT              1       1       " "    18    X_IEP                                      ""
19      SQLBIT              1       1       " "    19    X_IEP_ACCOM                                ""
20      SQLBIT              1       1       " "    20    X_ESL                                      ""
21      SQLNCHAR            2       4       " "    21    STUDENT_STATUS                             SQL_Latin1_General_CP1_CI_AS
22      SQLINT              0       4       " "    22    STUDENT_ID                                 ""
23      SQLINT              1       4       " "    23    ENG_PROF                                   ""
24      SQLNCHAR            2       60      " "    24    ALPHAKEY                                   SQL_Latin1_General_CP1_CI_AS
25      SQLNCHAR            2       20      " "    25    SCHOOL_ID                                  SQL_Latin1_General_CP1_CI_AS
26      SQLNUMERIC          1       19      " "    26    MN_EDE_NBR                                 ""
27      SQLNCHAR            2       20      " "    27    LANGUAGE_CODE                              SQL_Latin1_General_CP1_CI_AS
28      SQLINT              1       4       " "    28    ADVISOR                                    ""
29      SQLBIT              1       1       " "    29    MN_LIMITED_ENGLISH                         ""
30      SQLNCHAR            2       20      " "    30    TYPE_STUDENT_ID                            SQL_Latin1_General_CP1_CI_AS
31      SQLNCHAR            2       20      " "    31    CY_TEAM_SCHD_ID                            SQL_Latin1_General_CP1_CI_AS
32      SQLNCHAR            2       20      " "    32    HOMEROOM_NUMBER                            SQL_Latin1_General_CP1_CI_AS

This is my SQL table:

CREATE TABLE [dbo].[wbl_zSkywardEnrollment2](
    [SCHOOL_YEAR] [int] NOT NULL,
    [ENTITY_ID] [nvarchar](10) NOT NULL,
    [TERM_NBR] [int] NOT NULL,
    [SCHD_HST_GRAD_YEAR] [int] NULL,
    [OTHER_ID] [nvarchar](30) NULL,
    [GRAD_YR] numeric(19,0) NULL,
    [LAST_NAME] [nvarchar](60) NOT NULL,
    [FIRST_NAME] [nvarchar](30) NULL,
    [MIDDLE_NAME] [nvarchar](30) NULL,
    [BIRTHDATE] datetime NULL,
    [GENDER] [nvarchar](2) NULL,
    [RACE_CODE] [nvarchar](10) NULL,
    [DISTRICT_CODE] [nvarchar](20) NULL,
    [X_SPECIAL_EDUCATION] bit NULL,
    [X_GIFTED_TALENTED] bit NULL,
    [X_SECTION_504] bit NULL,
    [X_MIGRANT] bit NULL,
    [X_IEP] bit NULL,
    [X_IEP_ACCOM] bit NULL,
    [X_ESL] bit NULL,
    [STUDENT_STATUS] [nvarchar](2) NULL,
    [STUDENT_ID] [int] NOT NULL,
    [ENG_PROF] [int] NULL,
    [ALPHAKEY] [nvarchar](30) NOT NULL,
    [SCHOOL_ID] [nvarchar](10) NULL,
    [MN_EDE_NBR] [numeric](19, 0) NULL,
    [LANGUAGE_CODE] [nvarchar](10) NULL,
    [ADVISOR] [int] NULL,
    [MN_LIMITED_ENGLISH] bit NULL,
    [TYPE_STUDENT_ID] [nvarchar](10) NULL,
    [CY_TEAM_SCHD_ID] [nvarchar](10) NULL,
    [HOMEROOM_NUMBER] [nvarchar](10) NOT NULL
) ON [PRIMARY]

And I have tried this starting with row 1. I am curious which line should BCP start on? Line 1 of this XML starts with Schema and ElementType info. But on line 107 is where rs:data section starts.

The first part of this XML file:

<xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'

    xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'

    xmlns:rs='urn:schemas-microsoft-com:rowset'

    xmlns:z='#RowsetSchema'>

<s:Schema id='RowsetSchema'>

    <s:ElementType name='row' content='eltOnly'>

        <s:AttributeType name='c0' rs:name='SCHOOL_YEAR' rs:number='1'>

            <s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true' rs:maybenull='false'/>

        </s:AttributeType>

        <s:AttributeType name='c1' rs:name='ENTITY_ID' rs:number='2'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='10' rs:maybenull='false'/>

        </s:AttributeType>

        <s:AttributeType name='c2' rs:name='TERM_NBR' rs:number='3'>

            <s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true' rs:maybenull='false'/>

        </s:AttributeType>

        <s:AttributeType name='c3' rs:name='SCHD_HST_GRAD_YEAR' rs:number='4' rs:nullable='true'>

            <s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true'/>

        </s:AttributeType>

        <s:AttributeType name='c4' rs:name='OTHER_ID' rs:number='5' rs:nullable='true'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='24'/>

        </s:AttributeType>

        <s:AttributeType name='c5' rs:name='GRAD_YR' rs:number='6' rs:nullable='true'>

            <s:datatype dt:type='number' rs:dbtype='numeric' dt:maxLength='19' rs:scale='0' rs:precision='15' rs:fixedlength='true'/>

        </s:AttributeType>

        <s:AttributeType name='c6' rs:name='LAST_NAME' rs:number='7'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='60' rs:maybenull='false'/>

        </s:AttributeType>

        <s:AttributeType name='c7' rs:name='FIRST_NAME' rs:number='8' rs:nullable='true'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='30'/>

        </s:AttributeType>

        <s:AttributeType name='c8' rs:name='MIDDLE_NAME' rs:number='9' rs:nullable='true'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='30'/>

        </s:AttributeType>

        <s:AttributeType name='BIRTHDATE' rs:name='BIRTHDATE' rs:number='10' rs:nullable='true' rs:write='true'>

            <s:datatype dt:type='date' dt:maxLength='6' rs:fixedlength='true'/>

        </s:AttributeType>

        <s:AttributeType name='GENDER' rs:name='GENDER' rs:number='11' rs:nullable='true' rs:write='true'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='2'/>

        </s:AttributeType>

        <s:AttributeType name='c11' rs:name='RACE_CODE' rs:number='12' rs:nullable='true'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='6'/>

        </s:AttributeType>

        <s:AttributeType name='c12' rs:name='DISTRICT_CODE' rs:number='13' rs:nullable='true'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='14'/>

        </s:AttributeType>

        <s:AttributeType name='c13' rs:name='X_SPECIAL_EDUCATION' rs:number='14' rs:nullable='true'>

            <s:datatype dt:type='boolean' dt:maxLength='2' rs:fixedlength='true'/>

        </s:AttributeType>

        <s:AttributeType name='c14' rs:name='X_GIFTED_TALENTED' rs:number='15' rs:nullable='true'>

            <s:datatype dt:type='boolean' dt:maxLength='2' rs:fixedlength='true'/>

        </s:AttributeType>

        <s:AttributeType name='c15' rs:name='X_SECTION_504' rs:number='16' rs:nullable='true'>

            <s:datatype dt:type='boolean' dt:maxLength='2' rs:fixedlength='true'/>

        </s:AttributeType>

        <s:AttributeType name='c16' rs:name='X_MIGRANT' rs:number='17' rs:nullable='true'>

            <s:datatype dt:type='boolean' dt:maxLength='2' rs:fixedlength='true'/>

        </s:AttributeType>

        <s:AttributeType name='c17' rs:name='X_IEP' rs:number='18' rs:nullable='true'>

            <s:datatype dt:type='boolean' dt:maxLength='2' rs:fixedlength='true'/>

        </s:AttributeType>

        <s:AttributeType name='c18' rs:name='X_IEP_ACCOM' rs:number='19' rs:nullable='true'>

            <s:datatype dt:type='boolean' dt:maxLength='2' rs:fixedlength='true'/>

        </s:AttributeType>

        <s:AttributeType name='c19' rs:name='X_ESL' rs:number='20' rs:nullable='true'>

            <s:datatype dt:type='boolean' dt:maxLength='2' rs:fixedlength='true'/>

        </s:AttributeType>

        <s:AttributeType name='c20' rs:name='STUDENT_STATUS' rs:number='21' rs:nullable='true'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='2'/>

        </s:AttributeType>

        <s:AttributeType name='c21' rs:name='STUDENT_ID' rs:number='22'>

            <s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true' rs:maybenull='false'/>

        </s:AttributeType>

        <s:AttributeType name='c22' rs:name='ENGL_PROF' rs:number='23' rs:nullable='true'>

            <s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true'/>

        </s:AttributeType>

        <s:AttributeType name='ALPHAKEY' rs:name='ALPHAKEY' rs:number='24' rs:write='true'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='22' rs:maybenull='false'/>

        </s:AttributeType>

        <s:AttributeType name='c24' rs:name='SCHOOL_ID' rs:number='25'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='10' rs:maybenull='false'/>

        </s:AttributeType>

        <s:AttributeType name='c25' rs:name='MN_EDE_NBR' rs:number='26' rs:nullable='true'>

            <s:datatype dt:type='number' rs:dbtype='numeric' dt:maxLength='19' rs:scale='0' rs:precision='15' rs:fixedlength='true'/>

        </s:AttributeType>

        <s:AttributeType name='c26' rs:name='LANGUAGE_CODE' rs:number='27' rs:nullable='true'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='6'/>

        </s:AttributeType>

        <s:AttributeType name='c27' rs:name='ADVISOR' rs:number='28' rs:nullable='true' rs:write='true'>

            <s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true'/>

        </s:AttributeType>

        <s:AttributeType name='c28' rs:name='MN_LIMITED_ENGLISH' rs:number='29' rs:nullable='true'>

            <s:datatype dt:type='boolean' dt:maxLength='2' rs:fixedlength='true'/>

        </s:AttributeType>

        <s:AttributeType name='c29' rs:name='TYPE_STUDENT_ID' rs:number='30' rs:nullable='true'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='6'/>

        </s:AttributeType>

        <s:AttributeType name='c30' rs:name='CY_TEAM_SCHD_ID' rs:number='31' rs:nullable='true'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='6'/>

        </s:AttributeType>

        <s:AttributeType name='c31' rs:name='HOMEROOM_NUMBER' rs:number='32'>

            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='10' rs:maybenull='false'/>

        </s:AttributeType>

        <s:extends type='rs:rowbase'/>

    </s:ElementType>

</s:Schema>

<rs:data>

    <z:row c0='2004' c1='057' c2='0' c3='2010' c4='671590' c5='2010' c6='AANENSON' c7='SHELLI' c8='A' BIRTHDATE='1992-07-01'

         GENDER='F' c11='5' c12='' c13='False' c14='True' c15='False' c16='False' c17='False' c18='False' c19='False'

         c20='I' c21='12' c22='7' ALPHAKEY='AANENSHE000' c24='057' c25='624000671590' c26='011' ADVISOR='0' c28='False'

         c29='R' c30='' c31=''/>

    <z:row c0='2004' c1='057' c2='0' c3='2010' c4='671590' c5='2010' c6='AANENSON' c7='SHELLI' c8='A' BIRTHDATE='1992-07-01'

         GENDER='F' c11='5' c12='' c13='False' c14='True' c15='False' c16='False' c17='False' c18='False' c19='False'

         c20='I' c21='12' c22='7' ALPHAKEY='AANENSHE000' c24='057' c25='624000671590' c26='011' ADVISOR='0' c28='False'

         c29='R' c30='' c31=''/>

    <z:row c0='2004' c1='057' c2='0' c3='2010' c4='671590' c5='2010' c6='AANENSON' c7='SHELLI' c8='A' BIRTHDATE='1992-07-01'

         GENDER='F' c11='5' c12='' c13='False' c14='True' c15='False' c16='False' c17='False' c18='False' c19='False'

         c20='I' c21='12' c22='7' ALPHAKEY='AANENSHE000' c24='057' c25='624000671590' c26='011' ADVISOR='0' c28='False'

         c29='R' c30='' c31=''/>

    <z:row c0='2004' c1='057' c2='0' c3='2010' c4='671590' c5='2010' c6='AANENSON' c7='SHELLI' c8='A' BIRTHDATE='1992-07-01'

         GENDER='F' c11='5' c12='' c13='False' c14='True' c15='False' c16='False' c17='False' c18='False' c19='False'

         c20='I' c21='12' c22='7' ALPHAKEY='AANENSHE000' c24='057' c25='624000671590' c26='011' ADVISOR='0' c28='False'

         c29='R' c30='' c31=''/>

    <z:row c0='2004' c1='057' c2='0' c3='2010' c4='671590' c5='2010' c6='AANENSON' c7='SHELLI' c8='A' BIRTHDATE='1992-07-01'

         GENDER='F' c11='5' c12='' c13='False' c14='True' c15='False' c16='False' c17='False' c18='False' c19='False'

         c20='I' c21='12' c22='7' ALPHAKEY='AANENSHE000' c24='057' c25='624000671590' c26='011' ADVISOR='0' c28='False'

         c29='R' c30='' c31=''/>

    <z:row c0='2004' c1='057' c2='0' c3='2010' c4='671590' c5='2010' c6='AANENSON' c7='SHELLI' c8='A' BIRTHDATE='1992-07-01'

         GENDER='F' c11='5' c12='' c13='False' c14='True' c15='False' c16='False' c17='False' c18='False' c19='False'

         c20='I' c21='12' c22='7' ALPHAKEY='AANENSHE000' c24='057' c25='624000671590' c26='011' ADVISOR='0' c28='False'

         c29='R' c30='' c31=''/>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

记忆之渊 2024-09-23 10:02:47

您不能为此使用 bcpbcp 可以为您提供的最好功能是从带有逗号/制表符等的文件中导入。分离的值。您在 bcp 文档中看到的所有对 xml 的引用均指的是格式文件,而不是要导入的实际数据。

实际上有两种方法可以做到这一点。最简单的方法是使用 SQL Server Integration Services。 可以为您提供更多帮助。

您也可以通过 将 xml 文件读入 SQL Server。然后使用 sp_xml_preparedocument 解析该文件。最后,使用 OPENXML 结合 INSERT 以导入数据。

You can't use bcp for this. The best that bcp can give you is an import from a file with comma/tab/etc. separated values. All references that you see to xml in the bcp documentation refer to the format file, not to the actual data to import.

There are actually two ways of doing this. The easiest is to use SQL Server Integration Services for this. This can help you further.

You could also do this by reading the xml file into SQL server. Then use sp_xml_preparedocument to parse the file. Finally, use OPENXML in combination with INSERT to import the data.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文