Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSV import skips records

Status
Not open for further replies.

ElEye

IS-IT--Management
Nov 17, 2001
187
US
When I import a CSV into SQL Server 2005, my import is missing about half of the records. I know why it's doing this, but not how to fix it. I found that [Field5] of the first record in the CSV is an integer. However, about half of the records have alphanumberic values in that field and SQL server is skipping any records in the CSV that are not numeric.

Anybody have an idea how I can define the import fields using BULK INSERT or to tell SQL server to use [nvarchar](255) as the default for imports?


Here is my [tTable] design, which matches the CSV fields:
[Field1] [nvarchar](255) NULL,
[Field2] [nvarchar](255) NULL,
[Field3] [nvarchar](255) NULL,
[Field4] [nvarchar](255) NULL,
[Field5] [nvarchar](255) NULL,
[Field5] [nvarchar](255) NULL,
[Field6] [nvarchar](255) NULL,
[Field7] [nvarchar](255) NULL


Here is my import code:
BULK INSERT [tTable]
FROM 'C:\FilePath\Filename.csv'
WITH
(
FIRSTROW = 1,
TABLOCK,
MAXERRORS = 0,
FIELDTERMINATOR = ',',
ROWTERMINATOR = '0x0A'--'\n'
)


TIA,

Dave [idea]
[]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top