Nullable bool fields in MS Access linked tables

后端 未结 3 1337
无人及你
无人及你 2020-12-07 02:36

Looks like I\'m not the only one out there with this issue, but there doesn\'t seem to be an anwwer to this problem.

I\'m working in Access 2010, using a linked tabl

相关标签:
3条回答
  • 2020-12-07 02:49

    Following the analysis in this Microsoft KB http://support.microsoft.com/kb/318882 here is what we did to solve this problem. 1) We ran a sql script to update the rows in that table which had nulls in the bit fields, 2) We then modified the table definition to include a default value of '0' in those bit fields.

    0 讨论(0)
  • 2020-12-07 02:55

    ACE is an upgrade of Jet (forked from the Jet 4.0 codebase, which is maintained by the Windows team and not seeing any further development, while ACE is under full development by the Access team). It's not significantly different from Jet, except in that it's a new version of the database engine and has features that Jet lacked.

    Nullable Booleans are not one of the added features. In any case, if I'm not mistaken there are big theoretical arguments about whether Booleans should be Nullable and Jet/ACE comes down on the side that says they shouldn't be.

    Non-nullable Booleans cause problems even within Access/Jet/ACE (Allen Browne has discussed one such, with LEFT JOINs). My suggestion is that you change the field to a Nullable Bit, Byte or Integer field (I'm not sure what exact data types are in SQL Server, nor what is going to be most compatible with Access/Jet/ACE).

    Alternatively, you can approach it the way the BIGINT problem is dealt with by using a view to CAST() the server-side Boolean to an INT. That makes it non-editable but (as with BIGINT), you can keep the original field in the VIEW and write to that with appropriate values, while the CAST() version is for display only.

    For what it's worth, the SSMA for Access upsizes Jet/ACE Booleans to nullable bit fields (not sure why they are Nullable, though -- I may need to check some of my apps to make sure they are working correctly!).

    0 讨论(0)
  • 2020-12-07 02:59

    I experienced the same problem in my project, where I implement some add-ons in our old ordering system from early 2000's, and boolean is widely used.

    Today I found a solution by using a passthrough query as follows:

    SELECT 
        *,  
        CASE MYFIELD 
           WHEN NULL THEN NULL 
           WHEN 1 THEN 1 
           WHEN 0 THEN 0 
        END AS MYRESULT
    FROM 
        DBO.MYTABLE
    

    This is not updateable but anyway regular SQL statements work there.

    0 讨论(0)
提交回复
热议问题