• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 378
  • Last Modified:

SQL Server Import and Export Wizard

Hi All,

I would like to import a text file (see attached).

The text file has some information above the header rows, and the header rows and values do not start until several rows down.

I can import data easily if the file was structured purely in terms of header rows and the values but not so easily with the file attached.

I want to basically import the date and time into one table and then import the actual header row along with the values below it into another table.

I would be grateful if somebody had an idea of how to go about this manually so I can incorporate it into an SSIS package I'm trying to build.


1 Solution
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
SSIS doesn't handle multiple row types, so usually in this situation I would pump all of the rows into a table with a single column, then do some T-SQL to pick off the different types of rows (such as LEFT(column_name, 2) = 'H|' for headers, LEFT(column_name, 2) = 'D|' for detail, you get the idea. ), then more T-SQL to break them up into their respective columns, and write them to a staging table.

Or, write T-SQL to delete everything that's not a detail row, and work from there.

Hope this helps.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now