I am working on an Access DB, which have ODBC linked SQL Server table and local table, and I have following tsql script (as VB script) in Access DB. I am wondering if the tsql query can be made up of one linked table and one local Access table, instead of all are from linked tables. I know SQL Server does not know anything about my local data, but I just wonder if this coding can work or not. If yes, how should the following codes be modified? If no, that means I need to move the local table to SQL Server first? Appreciate if someone can advise. Thanks a lot.
The following section tries to update linked table from local table.
qryd.SQL = "
UPDATE dbo.linked_table
SET dbo.linked_table.field = '" & [local_access_table]![access_field] & "'
FROM dbo.linked_table
INNER JOIN " & [local_access_table] & "
ON ( '" & [local_access_table]![access_field] & "' = dbo.linked_table.field )
WHERE dbo.linked_table.field = 'value'
"
OR vice versa, this section below tries to update local table from linked table.
qryd.SQL = "
UPDATE " & [local_access_table] & "
SET '" & [local_access_table]![access_field] & "' = dbo.linked_table.field
FROM " & [local_access_table] & "
INNER JOIN dbo.linked_table
ON ( dbo.linked_table.field = '" & [local_access_table]![access_field] & "' )
WHERE '" & [local_access_table]![access_field] & "' = 'value'
"
Maybe my mindset is too much affected by Access, so I have other similar question. In Access, a select query(created in local Access) can be easily included in other Access query, I am wondering if this concept can be applied to tsql query? Take this as an example.
qryd.SQL = "
UPDATE dbo.linked_table
SET dbo.linked_table.field = '" & [local_access_query]![query_field] & "'
FROM dbo.linked_table
INNER JOIN " & [local_access_query] & "
ON ( '" & [local_access_query]![query_field] & "' = dbo.linked_table.field )
WHERE dbo.linked_table.field = 'value'
"
Thanks a lot!