简体   繁体   中英

MS Access frontend with SQL Server backend - integer key is out of range

I've a MS Access solution accessing to linked tables to SQL Server. Today it happens that one key filed in a table reached the limit of int.

So my first idea was to change it from int -> bigint but it seems to be not possible as ALTER queries return a couple of errors for.

The second idea was to clone the key field, delete original and make the clone to the new key field. This worked without problems but now the linked table only show #deleted values for all fields within the table. It seems that MS Access uses the keys for some relations when it access to the backend.

Maybe somebody know a solution to extend /reset the key without loosing the relation for MS Access?

Thank you

MsAccess has a "long integer" number option in the table design, which has the same size of INT from SQL Server. See below:

在此处输入图像描述

https://www.microsoft.com/en-us/microsoft-365/blog/2017/03/06/new-in-access-2016-large-number-bigint-support/

I found this: "Unfortunately, Access is unable to use BigInt as a primary key. You will most likely need to change this to a long integer. The article below is for an older version of Access, but the info still applies:" ( https://answers.microsoft.com/en-us/msoffice/forum/all/linked-table-showing-deleted-in-all-rows-and/d0451a78-08c1-4667-8677-6c61edcebcf1 )

So it seems not to be possible to use bigint as key.

I Googled this topic, and this is what I found...

Access CAN handle the BigInt datatype in SQL Server. Only, its handling of this is somewhat faulty.

As far as Access is concerned, BigInt is a STRING. You have to quote it as a string, within Access. Fortunately this isn't a problem on the SQL Server end, as SQL Server is happy with quoted numbers. In-between the two (Access and SQL Server), based on my experience, it appears there is a textual transmission of SQL commands from Access to SQL Server, with some modest dialect translation going on automatically in the background (if anyone knows better, please comment.) BigInt data coming from SQL Server to Access are automatically understood as strings.

https://social.msdn.microsoft.com/Forums/office/en-US/fb6f99ec-2ed7-487b-ba39-0777a0b44d5f/the-bigint-problem?forum=accessdev

MS Access is a 30 year old technology. Do you really want to be using that in 2022 and in the future?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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