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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How can you choose what fields to BULK INSERT?

Author  Topic 

steppinthrax
Starting Member

27 Posts

Posted - 2010-01-13 : 17:59:14
Ok here's the deal, I have a PIPE delimitered file that has MORE cols then the destination table. The Source file has 20 cols, however, the destination file has only the FIRST 9 COLS IN SEQUENCE.

Is there a way in bulk insert to specifiy the cols you want to insert based on a select statement.

I'm getting the following error.......

Msg 4863, Level 16, State 1, Procedure usp_positionControl_load, Line 18
Bulk load data conversion error (truncation) for row 1, column 9 (somecol).

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-01-13 : 18:13:19
I prefer to import data into a staging table that matches the file layout exactly. Then I can use T-SQL to move the data from the staging table into my actual table(s).

You could alternatively use a format file.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

steppinthrax
Starting Member

27 Posts

Posted - 2010-01-13 : 18:42:05
You are correct. I created a #temp and inserted into the #temp.
Go to Top of Page
   

- Advertisement -