November 7, 2009 at 12:34 pm
Hello all. First off, im not sure if this is the forum i should be posting this on. If it's not im sorry and please direct me to the correct one.
The scenario im in right now got me puzzled as to what to do (and boy, i like being puzzled).
Ok, so i have 5 .csv files to import, all separated by TAB (\t) with different amount of columns.
The application we have in the company import the files into a single table with the amount of columns i specify in the application, but the problem is: i need to specify the maximum amount of columns(22) but instead of inserting nulls for the columns missing on the files that have lesser columns the app just keeps inserting and filling those columns, which completly ruins queries i need to run later on.
Now, i can tell the application to import everything into a single varchar column.
what i did then was to add a new column to the table to know which file is which worked well if a cursor.
i then added a CHAR(9)(tab) before and after each line so i could separate every field with a tally table
so now i got a 1 column table with everything i need separated by file type, but i need to pivot it back into actual columns so i can create 5 temp tables to work with.
im not sure this is the correct approach, perhaps something simpler can be done but at this moment i cant think of any and would love some ideas
Thiago Dantas
--
Thiago Dantas
@DantHimself
November 7, 2009 at 8:30 pm
Double post... no discussion here, please. Keep it all together at the following URL... thanks.
http://qa.sqlservercentral.com/Forums/Topic815495-338-1.aspx
--Jeff Moden
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply