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.
Author |
Topic |
cobby1812
Starting Member
16 Posts |
Posted - 2011-11-25 : 09:56:38
|
Hi there,I am a bit new to Bulk Insert. I have a file that will come in daily as shown below1000000111111107400000000000000000000000021562BANK GIRO CREDIT 113281000000111111107400000000000000000000010223568BANK GIRO CREDIT 555555 11328I need to import this into a Database. I have created a Format file...as shown below4.2521 SYBCHAR 0 6 "" 1 BankSrtCode2 SYBCHAR 0 8 "" 2 BankAcctNumber3 SYBCHAR 0 3 "" 3 Type4 SYBCHAR 0 29 "" 4 Amount5 SYBCHAR 0 18 "" 5 Reference6 SYBCHAR 0 37 "" 6 Details7 SYBCHAR 0 5 "\r\n" 7 DateYet when I do it I get this errorMsg 4823, Level 16, State 1, Line 1Cannot bulk load. Invalid column number in the format file "d:\DebtorPaymentsFMT\DebtorPayments.fmt".Any help would be greatly appreciated. |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-11-25 : 10:13:06
|
Try canging the 52 to 7?==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
cobby1812
Starting Member
16 Posts |
Posted - 2011-11-25 : 10:17:03
|
Hi Nigel,OK that moved it on........now getting an error re the 4 SYBCHAR 0 29 "" 4 Amountas followsBulk load data conversion error (overflow) for row 12, column 4 (Amount).Msg 4867, Level 16, State 1, Line 1 |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-11-25 : 10:32:40
|
I think you have a problem with how you are tryiong to do the import or the file format.It looks like you are trying to import fixed length fields - which is ok as long as the non-fixed length data is at the end of the row. Looking at the data thought I think that 11328 is the date which means that the preceding data is variable length - you will need to use delimiters for this which doesn't look possible for that data. What is the 555555 in the second row.Think you would have to import into a single column table (without a format file) and parse it in sql server. A lot simpler than what you are trying to do.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
cobby1812
Starting Member
16 Posts |
Posted - 2011-11-25 : 10:45:49
|
Hi there,I thought as much....bummer. OK thank you for your help. Will insert into one column and strip it out from there. |
|
|
|
|
|