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
[]
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
[]