Importing a ''multiple'' space delimited text file into SQL

  • I am trying to import a text file (a log file generated by another program) into SQL. The log file on the face of looks nicely formatted, however upon closer inspection, they are not tabs or spaces but multiple spaces! the number of spaces can differ widely depending on the first columns value. Thus when I import this file I get lots of empty columns before a valid result shows up and it's not consistent across each row.

    Is there a type of import I can do which doesn't care about the number of spaces?

  • Is the file 'Fixed Field Length', that is each column is the same width which would describe your problem as the number of spaces would vary depending on how many characters there are in the column.

    If not then you could use DTS to import the data rows as single columns (transforming multiple spaces into one) into a staging table and then transform the staging table to your destination table.

    Far away is close at hand in the images of elsewhere.
    Anon.

  • I'd go for the staging table approach, I've done similar tasks in the past and have created a working table to manipulate the data in rather than attempting a straight and complex import.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply