需要有关如何在MS Access中使用VBA在MS SQL Server中复制表的帮助 [英] Need help in how to copy a table in MS SQL Server using VBA in MS Access

查看:78
本文介绍了需要有关如何在MS Access中使用VBA在MS SQL Server中复制表的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将CopyObject用于我的MS Access后端,该后端从现有的空表创建一个新表.
MS Access中的"DoCmd.TransferDatabase A_EXPORT,"ODBC数据库",..."代码可以在SQL Server中创建一个表,但不会复制主键,从而使SQL Server中的表不可更新.
我正在寻找一种从前端MS Access 2000以编程方式在SQL Server中创建空表(仅结构)的方法,所有表都带有索引和主键.

I use CopyObject for my MS Access back-end which creates a new table from an existing empty table.
The "DoCmd.TransferDatabase A_EXPORT, "ODBC Database",..." code in MS Access can create a table in SQL Server but primary key is not copied, rendering the table in SQL Server un-updateable.
I am looking for a way to programmatically create an empty table (structure only) in SQL Server from my front end MS Access 2000 all with indexes and primary key.

推荐答案

请参阅以下链接:
1)连接到SQL Server数据源 [创建表(Transact-SQL) [ ^ ]
两者都链接有示例.
See links below:
1) Connecting to a SQL Server Data Source[^]
2) CREATE TABLE (Transact-SQL)[^]
Both links with examples.


感谢您的响应.我要搬家时无法更早回复.

我使用DAO连接到SQL Server,所以ADO解决方案对我不起作用.

也许我可以通过"ALTER Table .."查询并通过"EXPORT"创建结构后将字段声明为主索引?

Skand
Thanks for the respone. Could not reply earlier as I am shifting apartment.

I use DAO to connect to SQL Server, so ADO solution will not work with me.

Perhaps I can pass through "ALTER Table.." query and declare a field as primary index after the structure is created through "EXPORT"?

Skand


这篇关于需要有关如何在MS Access中使用VBA在MS SQL Server中复制表的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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