Hi,
Does anyone know how to export a table to a text file through a SQL query?
Printable View
Hi,
Does anyone know how to export a table to a text file through a SQL query?
What database are you using?
Microsoft Access 2000 with ADO 2.6 through VB 6.0
You could use Access' built-in Export functionality - you'll need to add an Access object to your code and use Automation.
Or if XML is acceptable, you could look at the Save method of the recordset:
VB Code:
rst.Save "c:\myfile.xml", adPersistXML
Or, finally, you'll have to code it, looping through the recordset and writing to the file. This will be the most hard work, but will also give you greatest control...
I am looking for a query something like this to run in ADO:
db.Execute "SELECT * INTO [Text;database=c:\testdata]. HEADER0.txt from mytable"
The above query runs in DAO but not is ADO.
Any Help?