mrong
asked on
VBScript generate update SQL stmt
Greeting,
I have an input.txt with two columns and the following sample data. the empty strings between two columns are unknown.
input.txt
TOM JOHN
STEVE DAVE
Also I have TBL.txt with the following data
TBL1
TBL2
How to create a vbscript which will write to update.sql with the following output?
Update TBL1 set name='JOHN' where name='TOM';
Update TBL2 set name='JOHN' where name='TOM';
Update TBL1 set name='DAVE' where name='JOHN';
Update TBL2 set name='DAVE' where name='JOHN';
Please provide sample.
Thanks.
I have an input.txt with two columns and the following sample data. the empty strings between two columns are unknown.
input.txt
TOM JOHN
STEVE DAVE
Also I have TBL.txt with the following data
TBL1
TBL2
How to create a vbscript which will write to update.sql with the following output?
Update TBL1 set name='JOHN' where name='TOM';
Update TBL2 set name='JOHN' where name='TOM';
Update TBL1 set name='DAVE' where name='JOHN';
Update TBL2 set name='DAVE' where name='JOHN';
Please provide sample.
Thanks.
ASKER
Yes.
Try out the VBS code, then have a look in Query.SQL to see if it's right.
Rob.
Rob.
ASKER
TBL1
TBL2
are from TBL.txt file.
thanks
TBL2
are from TBL.txt file.
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Got the error message below.
Type mismatch: 'strNames'
Type mismatch: 'strNames'
ASKER
changed to the following and works.
Do While Instr(strLine, " ") > 0
strLine = Replace(strLine, " ", " ")
Loop
arrNames = Split(strLine, " ")
strColumn1 = arrNames(0)
strColumn2 = arrNames(1)
Do While Instr(strLine, " ") > 0
strLine = Replace(strLine, " ", " ")
Loop
arrNames = Split(strLine, " ")
strColumn1 = arrNames(0)
strColumn2 = arrNames(1)
Nice one. I was wondering whether it was going to work with varying spaces, but it looks like you did the right thing there.
Thanks for the grade,
Rob.
Thanks for the grade,
Rob.
ASKER
Thank you.
Update TBL1 set name='DAVE' where name='STEVE';
Update TBL2 set name='DAVE' where name='STEVE';
I think this should work for you.
Regards,
Rob.
Open in new window