Get the result of TOP N from a Flat file

  • HI,

    I have a huge flat file and i am not sure about the number of columns present in that. Is there any way to check / see the top 1..n rows from the Flat file ? Because i cudnt open the flat file since it is of huge in size.

    Thanks in Advance!

  • You could use bcp with -L option(last row).

    Set the field terminator to a non-existing character in that file (e.g. ~ or °) and import it into a table with only one column (+ addtl. id column).

    Use a split string function together with your field terminator to split the columns into rows. Based on the row number from your splitted data you'd know the number of columns.

    Sounds a little quick-and-dirty but that's the way I'd do it if I'd have to import a flat file with an (at the moment) unknown structure...

    But the question is: do you know for sure that the column structure you come up with is correct and will it be consistent for all rows once you start to import the large file?



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

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

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