简体   繁体   English

自定义链接到MS Access中的SQL Server的表

[英]Customizing the table linked to SQL Server in MS Access

Could you advise if there is a way to customize the data types and formats in linked table in MS Access connected to MS SQL database? 您能否建议是否有一种方法可以自定义连接到MS SQL数据库的MS Access中链接表中的数据类型和格式? Now I have the number looking like .00000 and dates shown as text. 现在我的数字看起来像.00000,日期显示为文本。

Thank you a lot! 非常感谢!

Data Types can only be changed by altering the source table in SQL Server. 只能通过更改SQL Server中的源表来更改数据类型 You can use Data Definition Language (DDL) SQL or an administration tool like SQL Server Management Studio to do this. 您可以使用数据定义语言(DDL)SQL或诸如SQL Server Management Studio之类的管理工具来执行此操作。

Here is an example of a DDL command: 这是DDL命令的示例:

ALTER TABLE yourTable ALTER COLUMN yourColumn nvarchar(100) NOT NULL;

If there is data in the column already, it must be convertible to the new data type. 如果该列中已经有数据,那么它必须可以转换为新的数据类型。

Formatting is not done on table level but in the user interface (eg form, report). 格式化不是在表级别进行,而是在用户界面(例如,表单,报告)中进行。 You can however define a default format for your data in the column properties of the table design view within Access. 但是,您可以在Access中的表设计视图的列属性中为数据定义默认格式。 This format will be used as default if this fields is displayed in the UI. 如果此字段显示在UI中,则将使用默认格式。

在表设计视图中设置列属性的格式

This is done the same way for linked tables as it is for local Access tables. 链接表的处理方法与本地Access表的处理方法相同。 And it works the same way, even though there is an info displayed, that you can't change this property. 即使显示了信息,它也以相同的方式工作,您无法更改此属性。 The format is stored locally in the Access database. 该格式存储在本地Access数据库中。 So keep in mind that you will lose all format settings in linked tables if you delete and relink the table. 因此请记住,如果删除并重新链接表,将丢失链接表中的所有格式设置。

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

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