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.

Thanks,

OS
testfile.txt
onesegunAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
Jim
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.