【问题标题】:MS ACCESS, VB Import External MS Access table into SQL server tableMS ACCESS, VBA 将外部 MS Access 表导入 SQL server 表
【发布时间】:2015-06-02 19:21:07
【问题描述】:

我有一个充当用户界面的 Access 数据库。 我在 Access 数据库中有一个链接的 SQL Server 2008 表。在用户界面上有用户选择的各种过滤器/标准(例如日期、外部 MS Access 数据库等。 这些都用于导入数据库。现在,我正在将用户选择的外部 MS Access 数据库导入到用户界面上的内部表中。 我的目标是将这些数据直接导入到 SQL 服务器表中。 这可能吗?

这就是我现在的做法。

 Dim Select_File as string
 Dim varFile as Variant
 Dim DBMonth as String
 DBMonth = Me.Month.Value '<-- this is just the Month that is either Default to current month of what user selects in a combobox on user interface
 ' there is some code here that has the user select the external access database and varFile is = .SelectedItems
 Select_File = varFile     
 DoCmd.TransferDatabase acImport, "Microsoft Access", Select_File, acTable, "Table_" & DBMonth & "_All", "Table"

因此,“表”表包含用户选择的外部 MS Access 数据库中的数据。 我想知道是否有一种简单的方法可以将该数据直接导入 SQL Server 表。 我试图将“表”名称更改为链接的 SQL Server 表,但它只是将其导入到一个名称相同的本地表中,并在其后加上“_1”。

【问题讨论】:

    标签: ms-access vba ms-access-2010


    【解决方案1】:

    我认为你可以通过执行“追加查询”来做你想做的事。

    我不确定名称,所以在这个例子中 [Table] 是包含源数据的原生 Access 表,[SQL Server Table] 是一个链接到服务器上的目标表。

    INSERT INTO [SQL Server Table] (Fld1, Fld2, Fld3)
    SELECT t.Fld1, t.Fld2, t.Fld3
    FROM [Table] AS t
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-09
      • 1970-01-01
      • 2017-04-27
      • 1970-01-01
      相关资源
      最近更新 更多