Click to See Complete Forum and Search --> : Transfer txt files into sql db
Karina Gámez
August 16th, 2001, 10:03 AM
I have a big.. big question....
Any idea about how can i transfer txt files from a vb application (im searching first on my directory or my network for all my txt files) into a "x" database sql server 7.0
urgent!
Thanks a lot!!!!!!!!!
phunkydude
August 20th, 2001, 05:59 AM
Are this arbitrary text documents that you want saved to a DB, or delimited text records?
If the files are delimited text records think of using BULK INSERT. (Check the SQL Server documentation for more info)
HTH
Karina Gámez
August 20th, 2001, 09:13 AM
Hi..
Thanks for u response..
but what i need is to use vb program or sentence.. to transfer file into a sql database
Thanks---
pd. the files are delimited by pipes
phunkydude
August 20th, 2001, 11:28 AM
My previous posting still applies:
sSQL="BULK INSERT .." & sTableName & " FROM '" & sPath2TextFileWithExt & "'"
sSQL=sSQL & " WITH (FORMATFILE = '" & sPath2FormatFileWithExt & "', DATAFILETYPE='char',TABLOCK)"
con2DB.execute sSQL, lRecordsAdded, adExecuteNoRecords
lRecordsAdded will return the number of records added (usually all or nothing).
Check up with the SQL Server documentation on the structure of the format file (column mapping, width, separators, blah, blah). I also included a teaser of the possible options that can be specified in the WITH () clause of the BULK INSERT.
Trust that the spoon feeding session will now lead you to the documentation.
Apologies if the remarks seem snide, but what i need is... ;)
Karina Gámez
August 20th, 2001, 11:34 AM
Thanks ...
Let me try..!
phunkydude
August 20th, 2001, 11:46 AM
The user that instantiated the connection MUST be a member of the sysadmins group.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.