批量插入-数据文件中第1行第36列的列过长

时间:2018-09-25 14:55:30

标签: sql sql-server csv tsql bulkinsert

我正在尝试从CSV文件在SQL Server 2017中进行批量插入。我不确定为什么会引发错误。这是我的SQL:

BULK INSERT dbo.Member_Household FROM 'C:\Users\CG160\OneDrive - XXXX XXXXX XX\XXXX\Member_Household No Headers.csv' 
with (fieldterminator = ',', rowterminator = '\n')

这是错误:

Msg 4866, Level 16, State 1, Line 1
The bulk load failed. The column is too long in the data file for row 1, column 36. Verify that the field terminator and row terminator are specified correctly.
Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "BULK" for linked server "(null)" reported an error. The provider did not give any information about the error.
Msg 7330, Level 16, State 2, Line 1
Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".

这是我的表模式:

CREATE TABLE [dbo].[Member_Household](
    [MembershipID] [int] NULL,
    [HouseholdID] [int] NULL,
    [OriginationDepartmentID] [int] NULL,
    [OriginationDepartmentName] [varchar](50) NULL,
    [ClosestDriveTimeDepartmentID] [int] NULL,
    [MemberOriginationDate] [date] NULL,
    [HouseholdOriginationDate] [date] NULL,
    [HasEStatements] [bit] NULL,
    [IsPrimaryHouseholdMembership] [bit] NULL,
    [MembershipType] [varchar](10) NULL,
    [FirstName] [varchar](50) NULL,
    [MiddleName] [varchar](50) NULL,
    [LastName] [varchar](50) NULL,
    [Suffix] [varchar](10) NULL,
    [Address1] [varchar](50) NULL,
    [Address2] [varchar](50) NULL,
    [City] [varchar](50) NULL,
    [State] [varchar](50) NULL,
    [Zip] [varchar](10) NULL,
    [BirthDate] [date] NULL,
    [EmailAddress] [varchar](254) NULL,
    [MarketAreaName] [varchar](50) NULL,
    [POECount] [int] NULL,
    [POEAsOfDate] [date] NULL,
    [Convenience] [bit] NULL,
    [Loans] [bit] NULL,
    [RealEstate] [bit] NULL,
    [Savings] [bit] NULL,
    [Transactional] [bit] NULL,
    [Wealth] [bit] NULL,
    [IsEngaged] [bit] NULL,
    [CensusTractName] [varchar](10) NULL,
    [TradeAreaName] [varchar](50) NULL,
    [MergerName] [varchar](100) NULL,
    [NoMarketingFlag] [bit] NULL,
    [NoMarketingEmailFlag] [bit] NULL
)

最后,这是我的CSV文件中的前几行数据:

3,199708,14,Tiffany Springs Branch,116,1992-07-01,1992-07-01,0,1,Trust,xxxx ,,ABBOTT,,xxx xxxx Ln,,Alameda,CA,945026830,1925-08-08,xxxx@HOTMAIL.COM,,0,2018-09-19,0,0,0,0,0,0,0,,,,0,0
4,16744,14,Tiffany Springs Branch,116,1974-03-01,1974-03-01,0,1,Person,xxxx,J ,xxxx,,181 xxxx Rd,,xxxx ,CA,945514933,1940-10-06,,,1,2018-09-19,0,0,0,1,0,0,0,,,,0,0
6,90728,14,Tiffany Springs Branch,17,1974-03-01,1974-03-01,0,1,Person,xxx,C ,xxx,,xxxx Pl,,Kansas City,MO,641552830,1929-08-24,xxxx@GMAIL.COM,North,3,2018-09-19,1,0,1,0,1,0,1,212.05,North Oak,,0,0

0 个答案:

没有答案