Jason,
as liziyu sugested, ado is the way to do it..
a quick tutorial:
There are 2 libraries you could use for this:
Microsoft ActiveX Data Objects (version) Library
or
Microsoft ActiveX Data Objects Recordset (version) Library
The first is a complete set of objects (ADODB) the second is a simplified verion (ADOR)
My example uses the first library.
--CODE--
'Needed ADODB objects
Dim oRs As ADODB.Recordset
Dim oCon As ADODB.Connection
'Needed strings
Dim strSQL As String
Dim ConnString as String
ConnString = "Provider=MSDASQL.1;Persist Security _
Info=False;User ID=admin;Data Source=ODBCNAME"
strSQL = "INSERT INTO Name _
SELECT a.id, a.name, use _
FROM 3Name a, 3ReplaceCompanyid b _
WHERE a.companyid = b.id"
'Preparations (making the connection,..)
Set oCon = New Connection
oCon.ConnectionString = ConnString
oCon.Open
Set oRs = New Recordset
oRs.CursorLocation = adUseClient
'Here's where you actually perform the SQL
oRs.Open strSQL, oCon, adOpenKeyset, adLockBatchOptimistic
'clean up
Set oRs.ActiveConnection = Nothing
Set oCon = Nothing
--/CODE--
regards,
Johan