tags:

views:

43

answers:

2

I am doing:

BULK INSERT CSVTest FROM 'c:\csvtest.txt'
WITH
(FIELDTERMINATOR = ',',
 ROWTERMINATOR = '\n')
GO

--Check the content of the table.
SELECT *
FROM CSVTest
GO

--Drop the table to clean up database.
SELECT *
FROM CSVTest
GO

Is it possible to insert only specific fields FROM the csv?

+2  A: 

You can do this using a format file. See: Using a Format File to Skip a Table Column and Using a Format File to Skip a Data Field.

Joe Stefanelli
As always, I don't mind a down vote if I'm wrong, but I do dislike an anonymous down vote with no explanation. Can you explain your objection?
Joe Stefanelli
+3  A: 

Alternatively, you can bulk insert into a view.

See also this question.

littlegreen