如何将记录从Access表复制到SQL Server DB [英] How can I copy records from Access Table to SQL Server DB

查看:79
本文介绍了如何将记录从Access表复制到SQL Server DB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将数据从访问表复制到sql服务器.我已经考虑过只链接表,但这对我想做的事情不起作用.单击宏按钮时,我需要将数据从访问表导出到sql服务器.关于如何着手或在哪里看有什么想法?

I need to copy data from an access table into sql server. I have thought about just linking the tables but this will not work for what I am trying to do. I need the data to export from the access table to the sql server when I click a macro button. Are there any ideas on how I can get started or where to look?

推荐答案

您的宏可以使用RunCode操作来运行类似于此功能的VBA函数:

Your macro could use the RunCode action to run a VBA function similar to this one:

Option Compare Database
Option Explicit

Public Function TransferTableToSqlServer()
    DoCmd.TransferDatabase _
            acExport, _
            "ODBC Database", _
            "ODBC;" & _
                "Driver={SQL Server Native Client 10.0};" & _
                "Server=(local)\SQLEXPRESS;" & _
                "Database=myDb;" & _
                "Trusted_Connection=Yes;", _
            acTable, _
            "sourceTableName", _
            "destinationTableName", _
            False
End Function

有关更多信息,请参见

DoCmd.TransferDatabase方法

这篇关于如何将记录从Access表复制到SQL Server DB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆