Solved

Vertical File into a Horizontal SQL Table

Posted on 2012-03-26
8
344 Views
Last Modified: 2012-03-30
All-

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.

Thanks…
Test-Data-for-EE.txt
0
Comment
Question by:GPCDIADMIN
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 9

Expert Comment

by:OCDan
ID: 37767947
What do you want your resultant table to look like?

p.s. that is one ugly ass flat file, whatever happened to commas :D
0
 

Author Comment

by:GPCDIADMIN
ID: 37768112
I would like Columns to be

ISA
GS
ST
BEG
REF
DTM
TD5
N9
MSG
N1
N3
N4
PER
PO1
PID
MSG
TXI
CTT
SE
GE
IEA


Thanks...
0
 
LVL 9

Expert Comment

by:OCDan
ID: 37768140
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?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:GPCDIADMIN
ID: 37768644
I am using an AS/2 connector to collect the files, I do not have control of changing the file format.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 37769523
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.
0
 
LVL 3

Expert Comment

by:tsnirone
ID: 37770704
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...
0
 

Author Comment

by:GPCDIADMIN
ID: 37771305
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.
0
 
LVL 3

Accepted Solution

by:
tsnirone earned 500 total points
ID: 37773851
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 :)
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL LINE CONTINUATION ISSUE 12 32
Querying data from 3 SQL tables 2 31
Help Required 3 93
Passing Parameter to Stored Procedure 4 23
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question