ms-access - 从 SSMS 导出到 MS Access 时保持表关系
问题描述
我目前正在为一个客户管理两个数据库。合同即将到期,他们要求我们在移交之前将他们的数据导出到 Access。
我注意到 Access 不保留表关系。SSMS 导出向导中似乎没有选项。将数据发送到 SSMS 时似乎也有解决方案,但反之则不然。这个问题还有其他解决方法吗?
解决方案
There is not a means to do the reverse.
However, what you can do is create a blank Access database. Link one table to sql server.
Then execute a transferDatabase command (it operates on one table).
the result of the above is that you now have all tables in Access. You WOULD have to re-create the relationships, but all PK and FK keys would be un-changed, and thus you can setup and re-create the relationships in Access. If you have say 25 tables? Then create a new table in that database (say my tables) and from SSMS execute a query to send all current tables in the database to that "table". (remove the MyTable - and perhaps any others you don't want to transfer).
Now, from the Access side, link to that MyTables, and process the rows for each table - executing a transfer Database command for each given table in that MyTale list. So at that point you have all data and tables in Access. As noted, you will have to re-create the relationships.
Another way? Just create a blank Access database. use the linked table wizard or the import wizard - you can import all tables in one shot. - you thus not need the above code. This is certainly the least amount of work. You can use the external data tab, and choose to create "links" or in fact local tables. So you can well with ease import all tables + data. But setting up and creating of the relationships will have to be done by manually (by hand).
推荐阅读
- docker - 当容器挂载主机的 Docker 套接字时,它是否也可以访问主机的凭据?
- r - 如何使带有数组的 R 代码更高效?
- python - 按钮按下不返回 Tkinter 中的 Line2D 对象
- c# - 禁用 TLS 1.0 和启用 TLS 1.2 破坏了 SMTP 测试代码
- python-3.x - django ModelSerializer 将变量传递给元子类
- qliksense - 在 Qlik Sense 上的标题表中更改颜色、移动和粗体文本
- angular - Ionic 4+ Capacitor Angular:如何为 ios 和 android 编写特定于平台的 ts 代码?
- r - 未能在 R 中验证谷歌翻译
- typescript - nestjs 如何工作并使用参数运行构造函数
- java - 从 Java 执行命令时出错(我正在做一个 Discord 机器人)