March 17, 2003 at 10:51 am
I have several fixed-width text files I am trying to import into SQL 6.5 using BCP. Some of which have variable record lengths. That is, the last field is not space-padded to the length of the field. Even worse, if the last field is null, the record ends with the previous field which again is not space-padded. Since the file is not delimited, the only terminator I am specifying is on the last field (\r\n).
HELP!!!
-Doug Lampe
-Doug Lampe
March 17, 2003 at 12:26 pm
If the field isn't padded then it isn't a fixed width file.
Do you mean that you have a \n at the end of every row?
Then bcp into a single column table (using the delimitter rather than fixed width) then use an SP to split the data into fileds.
>> if the last field is null, the record ends with the previous field
Do you mean that the field is missed out entirely? Then I don't see how you can deal with this file. How do you know the field is missed out?
Maybe you could post some examples.
Cursors never.
DTS - only when needed and never to control.
Edited by - nigelrivett on 03/17/2003 12:27:58 PM
Cursors never.
DTS - only when needed and never to control.
March 17, 2003 at 3:17 pm
I think I found the problem. I was specifying the row terminator in both the last record of the format file and the command line. This was causing part of the problem. As for the null fields being left off of the record, I took your advise (somewhat) and combined this with the prior field and parsed it after the BCP. Everything seems hunky-dory now.
-Doug Lampe
-Doug Lampe
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply