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)
 Inconsistent Bulk Insert

Author  Topic 

herbau
Starting Member

3 Posts

Posted - 2012-07-03 : 17:09:06
Here’s one that’s got me stumped. I found one old thread from someone with the exact same problem, but no clues.
The bulk statement works fine when run by itself. But when using EXEC, it will work for maybe 3-5 times, then give the error:

Cannot bulk load. Invalid destination table column number for source column 1 in the format file "D:\DMS_Import\_BAT_FMT_Files\CustOrds.fmt".

set @sql = 'BULK INSERT '+@BulkTableName+' FROM '+''''+ @FileToImport+''''+ ' WITH (FORMATFILE= '+''''+@FormatFile+''''+')'
EXEC(@sql)
The @sql value is:
BULK INSERT BULK_CustOrds FROM 'D:\DMS_Import\CustOrds.txt' WITH (FORMATFILE= 'D:\DMS_Import\_BAT_FMT_Files\CustOrds.fmt')

I need to do this in a loop so I can import many files with different formats. Any ideas?

herbau
Starting Member

3 Posts

Posted - 2012-07-05 : 16:16:58
A reinstall seems to have fixed the problem.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-07-05 : 16:31:47
quote:
Originally posted by herbau

A reinstall seems to have fixed the problem.



Thank you for posting back. Did the build number of SQL Server change for the reinstall? Like a service pack or hotfix/CU was installed that wasn't there previously?

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

Subscribe to my blog
Go to Top of Page
   

- Advertisement -