1

我一直在绞尽脑汁试图找出这个错误。我只是不明白。

SQL Server 数据库错误:第 1 行第 1 列 (CUR_CLM_UNIQ_ID) 的批量加载数据转换错误(溢出)。

这是我的代码:

SET DATEFORMAT ymd;
go
BULK INSERT 
aco.PartAClaimsHeader
FROM 'C:\Users\Derek\Documents\files\P.A1000.ACO.CCLF1.D120730.T1251070'
WITH
(
 --DATAFILETYPE ='CHAR',
  FORMATFILE='C:\Users\Derek\Documents\files\HeaderFileFormat.xml',
  --ERRORFILE='C:\Users\Derek\Documents\files\ERRORS.TXT',
  ROWTERMINATOR='\r\n',
  CODEPAGE='RAW',
 -- KEEPNULLS,
  TABLOCK
  )
  GO  

是固定宽度。这是一些示例数据

00190000777340000000000000109061100000924A 102012-01-182012-02-16323569   ~         0000000003522.44 12010000~1154529360~         1518945500~         
00158077735600000000000000100256140000646D 602011-07-222011-07-241141401  78650     0000000009238.12 12010247~1992759419159875707215987570721598757072
0022980857396000000000000010S191274000037A 602012-06-042012-06-08112988   2988      0000000002255.52 12010885~1760429880~         1831184316~         

这是我的格式文件

<?xml version="1.0"?>
<BCPFORMAT xmlns="http://schemas.microsoft.com/sqlserver/2004/bulkload/format" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<RECORD>
    <FIELD ID="1" xsi:type="CharFixed" LENGTH="13"/>
    <FIELD ID="2" xsi:type="CharFixed" LENGTH="13"/>
    <FIELD ID="3" xsi:type="CharFixed" LENGTH="6"/>
    <FIELD ID="4" xsi:type="CharFixed" LENGTH="11"/>
    <FIELD ID="5" xsi:type="CharFixed" LENGTH="2"/>
    <FIELD ID="6" xsi:type="CharFixed" LENGTH="10"/>
    <FIELD ID="7" xsi:type="CharFixed" LENGTH="10"/>
    <FIELD ID="8" xsi:type="CharFixed" LENGTH="1"/>
    <FIELD ID="9" xsi:type="CharFixed" LENGTH="1"/>
    <FIELD ID="10" xsi:type="CharFixed" LENGTH="7"/>
    <FIELD ID="11" xsi:type="CharFixed" LENGTH="7"/>
    <FIELD ID="12" xsi:type="CharFixed" LENGTH="2"/>
    <FIELD ID="13" xsi:type="CharFixed" LENGTH="17"/>
    <FIELD ID="14" xsi:type="CharFixed" LENGTH="1"/>
    <FIELD ID="15" xsi:type="CharFixed" LENGTH="2"/>
    <FIELD ID="16" xsi:type="CharFixed" LENGTH="2"/>
    <FIELD ID="17" xsi:type="CharFixed" LENGTH="4"/>  
    <FIELD ID="18" xsi:type="CharFixed" LENGTH="1"/>
    <FIELD ID="19" xsi:type="CharFixed" LENGTH="10"/>
    <FIELD ID="20" xsi:type="CharFixed" LENGTH="10"/>
    <FIELD ID="21" xsi:type="CharFixed" LENGTH="10"/>
    <FIELD ID="22" xsi:type="CharFixed" LENGTH="10"/>
    <FIELD ID="23" xsi:type="CharTerm" TERMINATOR="\r\n"/>
</RECORD>
<ROW>
    <COLUMN SOURCE="1" NAME="c1" xsi:type="SQLINT"/>
    <COLUMN SOURCE="2" NAME="c2" xsi:type="SQLINT"/>
    <COLUMN SOURCE="3" NAME="c3" xsi:type="SQLVARYCHAR"/>
    <COLUMN SOURCE="4" NAME="c4" xsi:type="SQLVARYCHAR" />
    <COLUMN SOURCE="5" NAME="c5" xsi:type="SQLTINYINT" />
    <COLUMN SOURCE="6" NAME="c6" xsi:type="SQLDATE"/>
    <COLUMN SOURCE="7" NAME="c7" xsi:type="SQLDATE"/>
    <COLUMN SOURCE="8" NAME="c8" xsi:type="SQLCHAR" LENGTH="1"/>
    <COLUMN SOURCE="9" NAME="c9" xsi:type="SQLCHAR" LENGTH="1" />
    <COLUMN SOURCE="10" NAME="c10" xsi:type="SQLVARYCHAR" />
    <COLUMN SOURCE="11" NAME="c11" xsi:type="SQLVARYCHAR"/>
    <COLUMN SOURCE="12" NAME="c12" xsi:type="SQLCHAR" LENGTH="2"/>
    <COLUMN SOURCE="13" NAME="c13" xsi:type="SQLDECIMAL" SCALE="2" PRECISION="17"/>
    <COLUMN SOURCE="14" NAME="c14" xsi:type="SQLCHAR" LENGTH="1" />
    <COLUMN SOURCE="15" NAME="c15" xsi:type="SQLCHAR" LENGTH="2" />
    <COLUMN SOURCE="16" NAME="c16" xsi:type="SQLCHAR" LENGTH="2"/>
    <COLUMN SOURCE="17" NAME="c17" xsi:type="SQLVARYCHAR"/>
    <COLUMN SOURCE="18" NAME="c18" xsi:type="SQLCHAR" LENGTH="1"/>
    <COLUMN SOURCE="19" NAME="c19" xsi:type="SQLCHAR"  LENGTH="10"/>
    <COLUMN SOURCE="20" NAME="c20" xsi:type="SQLCHAR" LENGTH="10" />        
    <COLUMN SOURCE="21" NAME="c21" xsi:type="SQLCHAR"  LENGTH="10"/>        
    <COLUMN SOURCE="22" NAME="c22" xsi:type="SQLCHAR"  LENGTH="10"/>        
    <COLUMN SOURCE="23" NAME="c23" xsi:type="SQLCHAR" />                
</ROW>
</BCPFORMAT>

更新:我在 db 和格式化文件中将前 2 个 INT 更改为 VARCHAR,它没有问题。想保留他们的INT。

4

0 回答 0