Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 Variable row lengths

Author  Topic 

benking9987
Posting Yak Master

124 Posts

Posted - 2012-09-07 : 13:28:38
I have an Import/Export routine that grabs a .txt file and pulls it into a buffer table in my SQLServer 2005. The .txt file is fairly straight forward except for one anomaly.

This is an order file given to me from a large e-commerce company, so to begin...there is nothing I can do to change the way I'm getting the data. A specific type of record that they send through on the file has the row delimiter (CR/LF) at the end of column #65 but the rest of the file goes to 73 columns. So it looks like this:

REGULAR ROW
Field1<tab>Field2<tab>Field3<tab>...Field73<CR/LF>

ANOMALY ROW
Field1<tab>Field2<tab>Field3<tab>...Field65<CR/LF>

Because there are not column delimiters<tab> to fill out the rest of the rows, the data in the row immediately following the anomaly row gets messed up.

Can anyone think of a way to get the data to flow in smoothly, so the Import/Export setup knows to always start a new row at the CR/LF. In the Source data setup, {CR}{LF} is CLEARLY chosen as the Row delimiter.

Any help is much appreciated.

Thanks in advance.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-09-09 : 12:57:51
i think best thing would be to use ssis package and parse data file using script task and insert the missing tabs in cases column dont exists (anamoly rows). then giving it to normal data flow task should run export smoothly

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

benking9987
Posting Yak Master

124 Posts

Posted - 2012-09-10 : 16:24:10
Thanks visakh16. I think I'm officially out of my league on your suggestion as I have no experience writing a custom script to parse the data. I do know a pretty good programmer/developer locally and I'll see if he can help me get in the right direction.

Thanks
Go to Top of Page
   

- Advertisement -