Wednesday, March 7, 2012

ODBC Text file to SQL conversion

I have a large comma delimited text file (130K records) that I want to convert to an SQL data file. I want to use this data file as a datasource in a Visual Basic 2005 application.

Can I use the txt file directly?

If not, how can I convert/import the data into an SQL data file?

Thanks, Bob

Steve Kass has good info:
http://www.users.drew.edu/skass/sql/TextDriver.htm

You could also use openrowset() to query the data.

exec master..xp_cmdshell 'echo "this is a test" >> c:\temp\test.txt & echo
"this is a test2" >> c:\temp\test.txt'
go
select *
from OpenRowset('Microsoft.Jet.OLEDB.4.0',
'Text;Database=c:\temp\;HDR=NO',
'select * from test.txt')

No comments:

Post a Comment