November 12, 2013 at 11:05 am
Hi all,
I am running SQL Server 2008R2 and trying to import .csv file data into a table.
The problem is that i have some values in the file that are missing (NULL).
Data:
1,
9999000002,
8888000004,
7777000019,0016000000KOCoG
7777000020,0016000000fGXCb
6666000021,
5555000022,
Table:
CREATE TABLE [dbo].[A](
[coid] [varchar](256) NULL,
[said] [varchar](15) NULL
);
Code:
bulk insert dbo.A
from 'C:\TEMP\temp.csv'
with (
fieldterminator = ','
,rowterminator = ''
);
Error:
Msg 4864, Level 16, State 1, Line 1
Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 1 (coid).
Question: is there way to filter NULL values? Perhaps there is another way, besides bulk insert to do it?
Thanks,
November 12, 2013 at 11:27 am
rightontarget (11/12/2013)
Hi all,I am running SQL Server 2008R2 and trying to import .csv file data into a table.
The problem is that i have some values in the file that are missing (NULL).
Data:
1,
9999000002,
8888000004,
7777000019,0016000000KOCoG
7777000020,0016000000fGXCb
6666000021,
5555000022,
Table:
CREATE TABLE [dbo].[A](
[coid] [varchar](256) NULL,
[said] [varchar](15) NULL
);
Code:
bulk insert dbo.A
from 'C:\TEMP\temp.csv'
with (
fieldterminator = ','
,rowterminator = ''
);
Error:
Msg 4864, Level 16, State 1, Line 1
Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 1 (coid).
Question: is there way to filter NULL values? Perhaps there is another way, besides bulk insert to do it?
Thanks,
Stop using a blank as a row terminatior and this problem will go away.
--Jeff Moden
Change is inevitable... Change for the better is not.
November 12, 2013 at 12:00 pm
Just to expand a little on Jeff's answer. You can use as the row terminator (new line character).
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply