excel vba - VBA - Need to append to the end of a line in a large text -
i have system can read 50 column's worth of data table @ time. table has 150 columns need read. table has 1 million lines.
what have been doing far read 1st 50 columns , write 1 millions lines text file.
what need next, read next block of 50 columns , append lines 1 1 million existing text file have written to.
this become stuck. i'm not sure how can write specific line in text file. hoping not have loop each line in existing text file row need append to. there way specify line need append without having loop text file find correct row?
i use sql oledb , output data using recordset. might take time should work. try using limit
, fetch
in loop in case result won't load in single go. alternatively add loop sql statement , fetch records higher lower specific row id (if records id numeric not hash) e.g. where id > [old_id] , id <= [old_id] + 100
using sql oledb , recordset
dim filename string, textdata string, textrow string, fileno integer fileno = freefile open filename output #fileno set rs = createobject("adodb.recordset") sconn = "oledb;provider=sqloledb;data source=" & _ serverinstance & ";initial catalog=" & database & _ ";user id=" & userid & ";password=" & password & ";" strsql = "select * [table_name] " rs.open strsql, strcon, 3, 3 rs.movefirst textdata = "" textdata = textdata & ";" & rs("col1") textdata = textdata & ";" & rs("col2") textdata = textdata & ";" & rs("col3") & vbnewline print #fileno, textdata rs.movenext loop until rs.eof close #fileno
Comments
Post a Comment