Vertical File into a Horizontal SQL Table


I have an issue where I am trying to import a flat file that is set up vertically and I need to set up a table in SQL.  I have provided a couple of some test data.  Any direction would be appreciated, I would prefer to handle this via a DTS package to collect the file and import it directly into a table.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

What do you want your resultant table to look like?

p.s. that is one ugly ass flat file, whatever happened to commas :D
GPCDIADMINAuthor Commented:
I would like Columns to be


Someone else may have an answer but there doesn't seem to be any common delimeters to me so creating a generic script would be damn near impossible.

You could hardcode some charindex code in there but again given the lack of continuity searching for 2-4 characters would likely result in a lot of anomalous results.

Can you get that flat file changed at all? Are you sent this or are you creating this yourself?
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

GPCDIADMINAuthor Commented:
I am using an AS/2 connector to collect the files, I do not have control of changing the file format.
Anthony PerkinsCommented:
Ah yes, the infamous EDI format.  I would suggest you build an application using .NET to handle this.

>>I would like Columns to be <<
Unless you use very generic varchar columns allowing for the maximum length you will not be able to do this.
As long as the files you receive conforms to a standard where you can "divide" the input into columns (Seems the "~" is columnseparator(?) - is this X12?) I see no problem in importing this data into a table and massage it in (ie) stored procedure to your liking...
GPCDIADMINAuthor Commented:
Correct this is X12 style, I had some thoughts last night I am going to try out.  It will be lengthy but I wanted to see if anyone has done this before through a DTS or SQL in general.
I tried to search to find a stored procedure for you that you could alter/build on but was unsuccessful :(

In a stored procedure tho, you can do just about anything, so I'd import the data into a temp-file and go (lengthy) from there.

Good luck :)

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

From novice to tech pro — start learning today.