Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21453

BULK INSERT Text Files into SQL/Oracle

$
0
0
Good Morning All,

I have a table in SQL called [RU].[MainTab]. It contains the following fields:

CKale (nvarchar, 5)
Checkdt (date)
RecDate (date)
PersonID (nvarchar, 6)

I have a folder on my hard drive containing numerous delimited text files, each one with data that corresponds to the SQL table. Example:

12345,4/5/2013,4/6/2013,123456

The code posted below is intended to take all those text files, combine then into one (called "Combined.txt"), and then do a BULK INSERT to append the contents of Combined.txt into the SQL table.

The combining of the text files works great. The BULK INSERT errors out, only because I can't grant myself BULKADMIN server permissions (I think).

Here are my questions:

1. Can someone look at the code, focusing on the part after the text files are combined, and tell me if you think it should work if I were to have BULKADMIN permission to SQL Server? If not, what needs changed?

2. How would this code differ if I were connecting to an Oracle database versus SQL Server? I'm assuming the DRIVER in the Connection String would change, but once the connection is open, would there be any difference in the BULK INSERT statement?

Viewing all articles
Browse latest Browse all 21453

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>