Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TXT File to SQL TABLE

Status
Not open for further replies.

SQLBaby

IS-IT--Management
Jan 3, 2003
158
US
I never use VB, but may be any body help me.
Well, i need to get data from text file and want to save it in SQL table. I can get it through SQL directly but the problem is data is not in sequence in .txt file. for example the text file is look like

Company name, date, time, address..... 9Some other information) then

Acct:00100,EXP,114
REG: $44000.00 OVERTIME: $16500.00
ACCT:00100,EXP,131
REG: $81000.00 PERSONAL: $15000.00 HOLIDAY: 5424.00

ACCT:00100,EXP,080
SALREG: $45678.00 VAATION: 25000.00 ....etc etc

i need to get information and save in the the specific column. like..
00100 will save in Dep. number
EXP will save in Department name
080 will save in code
all different valuse will be saved in their related columns like

Reg: $81,000.00 will save as 81000.00 in Salary columns.

The point is informations in TX file are not in sequence, like some department do not have overtime and some do not have holidays pay this week etc etc

Can any body help me for that.

Thanks in Advance

Knowledge is a key of success.



 
Load the file and parse it yourself.

You could use instr as a way to look for the headings and then set variables based on the values that follow.

Then you either build a query string and insert the new data or you can open a recordset and add a new record.

If you are updating and existing record- same deal.

A select case statement would probably be handy- work your way through the record and see what is there that you need, don't worry about what isn't there.

 
open it at excell and do a macro to format your data, then save it again as text.

--
Luis MX
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top