简体   繁体   English

从MS Access中的表自动更新SQL Server数据库

[英]Automatically update SQL Server database from tables in MS Access

I'm new to SQL Server and trying to automatically update tables in SQL Server from tables in MS Access. 我是SQL Server的新手,并尝试从MS Access中的表自动更新SQL Server中的表。

I have an Access database of metadata that must be kept updated for sending records to other groups. 我有一个元数据的Access数据库,必须保持更新才能将记录发送到其他组。 I also have a database in SQL Server which also has these same metadata tables. 我在SQL Server中也有一个数据库,它也有这些相同的元数据表。 Currently these tables in the SQL Server database get updated manually by exporting the Access tables as Excel files, and then importing them into the SQL Server tables. 目前,SQL Server数据库中的这些表通过将Access表导出为Excel文件,然后将它们导入SQL Server表来手动更新。

It's not the most efficient process and could lead to errors in the SQL Server database if someone forgets to check that they are using the most recent data from Access. 这不是最有效的过程,如果有人忘记检查他们是否正在使用来自Access的最新数据,那么可能会导致SQL Server数据库出错。 So I would like to integrate some of the tables from Access to my database in SQL Server. 所以我想将Access中的一些表集成到SQL Server中的数据库中。 Ideally I would like for the tables in my SQL Server database to be updated whenever Access is updated or at least update the tables automatically in the SQL Server database when I open it. 理想情况下,我想在更新Access时更新SQL Server数据库中的表,或者至少在打开它时在SQL Server数据库中自动更新表。

Would replicating the Access tables be the best? 复制Access表是最好的吗? I am using SQL Server 2014 Developer so I think I have this capability. 我正在使用SQL Server 2014 Developer,所以我认为我有这个功能。 From my understanding, mirroring is for an entire database not just pieces of it. 根据我的理解,镜像是针对整个数据库而不仅仅是它的一部分。 However, I do not want to be able to alter the metadata from SQL Server and have it reflected in Access. 但是,我不希望能够从SQL Server更改元数据并将其反映在Access中。 I cannot tell if reflecting the tables would do this...? 我不知道反映表是否会这样做......?

I also looked at this post about writing multiple insert statements but was confused ( What is the best way to auto-generate INSERT statements for a SQL Server table? ). 我也看过这篇关于编写多个insert语句的帖子,但是很困惑( 为SQL Server表自动生成INSERT语句的最佳方法是什么? )。 Someone else suggested importing all the data into SQL Server and then using an ODBC driver to connect the two, but I'm also not sure how this would update the database in SQL Server anytime Access is updated. 其他人建议将所有数据导入SQL Server,然后使用ODBC驱动程序连接这两个,但我也不确定如何在更新Access时更新SQL Server中的数据库。

If you have any suggestion and a link to easy to follow tutorial I would really appreciate it! 如果您有任何建议和易于学习的教程链接,我将非常感激!

Thanks 谢谢

In Access, go to 'External Data', ODBC Database, and connect to the SQL Server database directly - make sure you select 'Link to the data source by creating a linked table' on the first page of the wizard. 在Access中,转到“外部数据”,ODBC数据库,并直接连接到SQL Server数据库 - 确保在向导的第一页上选择“通过创建链接表链接到数据源”。 Now, this linked table is available in Access, but is actually the SQL Server table. 现在,此链接表在Access中可用,但实际上是SQL Server表。

Get rid of the local Access tables, using the new linked tables in their place in whatever queries, forms, reports, etc that you have in Access. 摆脱本地Access表,在Access中的任何查询,表单,报告等中使用新的链接表。

Now, any changes to the tables you see in this Access db ARE changes to the SQL Server database. 现在,您在此Access数据库中看到的表的任何更改都将更改为SQL Server数据库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM