Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 bulk insert

Author  Topic 

robcpettit
Starting Member

11 Posts

Posted - 2013-10-09 : 12:31:09
Hi Im bulk inserting from a csv file using
BULK INSERT testTable
FROM 'C:\Users\Robs\Documents\Soccer\2011-2012\SC1.csv'
WITH
(
FIRSTROW=2,
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n',

)
Works fine. Most of my csv files have the same number of columns, but some have 4 less. The files contain the same column headings as the full size ones(only 4 less). Is there a way when bulk inserting for sql to either skip these, or ignore the error. Much Appreciated
Robert

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2013-10-09 : 12:50:24
I would create a testTable2 with this other layout.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2013-10-09 : 16:53:21
Any luck you can use SSIS? The flat file connector has Ragged right option.



Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page
   

- Advertisement -