简体   繁体   English

将表从Ms-Access传输到SQL Server

[英]Transfer table from Ms-Access to SQL Server

I don't have much experience with SQL Server, I use it currently to run some simple queries, and I link to SQL tables from Access where I have all my heavy queries. 我对SQL Server没有多少经验,我目前用它来运行一些简单的查询,我从Access中链接到SQL表,我在那里遇到了所有繁重的查询。 My goal is to run all of my queries in Access daily and then at the end write the finished tables up to SQL where my Access front end will read them (versus keeping them in my Access backend). 我的目标是每天在Access中运行我的所有查询,然后在最后将完成的表写入SQL,我的Access前端将读取它们(而不是将它们保存在我的Access后端)。

I've tried messing around with the code below to try and figure out how to do this, but I'm stuck at the driver and I can't find any references on how to do this with just a single table. 我已经尝试弄乱下面的代码来试图弄清楚如何做到这一点,但我坚持在驱动程序,我找不到任何关于如何只用一个表做这个的参考。 Let's call it "PO_STATUS_TBL" 我们称之为“PO_STATUS_TBL”

Public Sub ADOtest()

   Dim ADOConn As New ADODB.Connection
   Dim ADOCom As New ADODB.Command


   On Error Resume Next

   ADOConn.ConnectionString = "Driver =(SQL Server);DRIVER=SQL Server;SERVER=BUSINESS_BWP;Trusted_Connection=Yes"
   ADOConn.Open

   Debug.Print ADOConn.State

   Dim db As Database
   Set db = CurrentDb

   'db.Execute "INSERT INTO [ODBC;DRIVER=SQL Server;ENCSQL28\BUSINESS_BWP;DATABASE=CurrentDb].SFTransfersDB ( ID, TO ) SELECT ID,TO FROM SFTransfersDB"

End Sub

I went through this process lately. 我最近经历了这个过程。

For migration you can use this tool by Microsoft . 对于迁移,您可以使用Microsoft的此工具 With this tool you can either migrate a table or a query to MS-SQL - or even both. 使用此工具,您可以将表或查询迁移到MS-SQL - 甚至两者。 Even with relations. 即使有关系。

Simple export with this wizard and add your one table through ODBC Connector in Access. 使用此向导进行简单导出,并通过Access中的ODBC连接器添加一个表。 Important is to have the correct ODBC Driver. 重要的是拥有正确的ODBC驱动程序。

If you are interested I resolved this issue with Parfait's advise. 如果您有兴趣,我用Parfait的建议解决了这个问题。 By using a simple INSERT statement. 通过使用简单的INSERT语句。

INSERT INTO Dbo_PO_STATUS_ALL_TBL Select * FROM PO_STATUS_ALL_TBL

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

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