|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2004-11-10 : 08:27:11
|
| Elton writes "I think i'm driving myself mad trying to do this.I am trying to import data from a text file into sql, sounds quite easy right. The following is sample data i want to import.DPLRMain 672,'651018053','DD1000000729','PRICC','PRICC','19991111','1447','THEA,M CPT','','19991111','1447','THEA,M CPT','','','6510','19991111','','','','','U','19991111','','','DSP'DPLRBill 672,'19991111','1','L','0.0002','NEW','1','5.50','1447','THEA,M CPT','','19991111','','','','DSP'DPLRBill 672,'19991111','2','L','1000.0000','NEW','1','49.20','1447','THEA,M CPT','893','19991111','','','','DSP'DPLRBill 672,'19991111','3','L','1205.0000','NEW','1','10.60','1447','THEA,M CPT','893','19991111','','','','DSP'DPLRBill 672,'19991111','4','L','3182.0000','NEW','1','24.30','1447','THEA,M CPT','894','19991111','','','','DSP'DPLRBillCode 672,'L0.0002','4543D0006510.~651018053,6610*PRICC','','','DSP'DPLRBillCode 672,'L1000.0000','3755H0006502.~651018053,6610*PRICC','','','DSP'DPLRBillCode 672,'L1205.0000','3797H0006502.~651018053,6610*PRICC','','','DSP'DPLRBillCode 672,'L3182.0000','4001B0006501.~651018053,6610*PRICC','','','DSP'DPLREEPAT 672,'','','','','','','','','','DSP'DPLRLabOrdTest 672,'0.0002','1','1','5.50','','','','','','','','','DSP'DPLRLabOrdTest 672,'1006.0000','1','1','','','','','893','','','','','DSP'DPLRLabOrdTestComp 672,'1006.0000','1000.0000','1','49.20','','DSP'DPLRLabOrdTestComp 672,'1006.0000','1205.0000','1','10.60','','DSP'DPLRLabOrdTest 672,'3182.0000','1','1','24.30','','','','894','','','','','DSP'DPLRLabSpec 672,'BA','1','894','','DSP'DPLRLabSpec 672,'HA','1','893','','DSP'What this basically means is that these records need to go to different tables. I have got two working ways of importing the data1) I use a generic program that loops through a folder, picks up the files and then imports the data via a stored proc, everything starting with DPLR in the sample above are different procs. This works quite well, just extremely slow depending on the volume of data as it process one record at a time.2)I wrote a little script that does exactly the same thing using dts. I sit with the same problem.The other disadvantage is I have to many stored procs.I am thinking of another way of doing this, have not yet had time to think it through or try it yet. I am thinking of using a temp table with maximum number of colums, then dumping all the data into that table, instead of having the proc name I'll replace it with a table name, then I'll have one proc that does a select insert or bulk insert for all the data with the same table. As I said before, have not really tried this as yet, am not even to sure even if it would work or not.I am quite sure I'm not the first and surely not the last person to attempt this. So please if any one anywhere has any ideas on how I could go about this, I would really appreciate the help.Thanking you in advance.Elton" |
|