Editing Record issues in Access / SQL (Write Conflict)

后端 未结 13 2469
-上瘾入骨i
-上瘾入骨i 2020-12-05 22:44

a problem has come up after a SQL DB I used was migrated to a new server. Now when trying to edit a record in Access (form or table), it says: WRITE CONFLICT: This re

13条回答
  •  醉酒成梦
    2020-12-05 23:23

    I found the problem due to the conflict between Jet/Access boolean and SQL Server bit fields.

    Described here under pitfall #4 https://blogs.office.com/2012/02/17/five-common-pitfalls-when-upgrading-access-to-sql-server/

    I wrote an SQL script to alter all bit fields to NOT NULL and provide a default - zero in my case.

    Just execute this in SQL Server Management Studio and paste the results into a fresh query window and run them - its hardly worth putting this in a cursor and executing it.

    SELECT
        'UPDATE [' + o.name + '] SET [' + c.name + '] = ISNULL([' + c.name + '], 0);' + 
        'ALTER TABLE [' + o.name + '] ALTER COLUMN [' + c.name + '] BIT NOT NULL;' + 
        'ALTER TABLE [' + o.name + '] ADD  CONSTRAINT [DF_' + o.name + '_' + c.name + '] DEFAULT ((0)) FOR [' + c.name + ']'
    FROM
        sys.columns c
    INNER JOIN sys.objects o
    ON  o.object_id = c.object_id
    WHERE
        c.system_type_id = 104
        AND o.is_ms_shipped = 0;
    

提交回复
热议问题