Link to home
Start Free TrialLog in
Avatar of gotreply
gotreply

asked on

import flat file into two tables

trying to load a text files into 2 mssql tables. the text file contains rows of record where if it starts with H (header) will go to tab1 & if it starts with numeric will go to tab2.

example of the text file are like this
http://www.geocities.com/alexlow2020/sample.txt

and i have to import into below table
http://www.geocities.com/alexlow2020/table.jpg

the text file have fix char location & i have to extract it out to put into specific col.

anyone have any ideas how to do this or done it b4 ? thanks

Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

For ANY kind of import, i do import to a staging table first, which has only varchar field(s). Then, with "simply" SQL, i can validate the data, and move it around to other tables, eventually other staging tables.

You will have to write some long SQL, specifiying all the columns, splitting up the data, but you can be assured that this is the most easy-to-support and flexible solution i found until now.

CHeers
ASKER CERTIFIED SOLUTION
Avatar of gotaquestion
gotaquestion

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gotreply
gotreply

ASKER

thks for the help, have solve it after various try, ur comment did give me some idea to furthur my experiment.