Moving from text to varchar(MAX): Are there any troubles to expect with MS Access?

前端 未结 5 1903
感动是毒
感动是毒 2020-12-20 00:44

It is well-known that MS Access applications (MDBs) using SQL Server backends have trouble with certain data types. For example,

  • bit field sup
5条回答
  •  眼角桃花
    2020-12-20 01:24

    This is an addendum to the answer by JStevens.

    The newer ODBC drivers for SQL Server limit VARCHAR(MAX) to 8000 characters. Trying to enter more text via a linked ODBC table results in this ODBC error:

    [Microsoft][ODBC Driver 17 for SQL Server]String data, right truncation (#0)

    It works with the ancient {SQL Server} driver, or with data type TEXT.
    And surprisingly, it also works with NVARCHAR(MAX) !

    These findings are with Access 2010 or 2016, and SQL Server 2008 R2.

    +--------------------+--------------+---------------------------------+
    | Data type \ Driver | {SQL Server} | {ODBC Driver 17 for SQL Server} |
    +--------------------+--------------+---------------------------------+
    | VARCHAR(MAX)       | ok           | ODBC Error                      |
    | NVARCHAR(MAX)      | didn't try   | ok                              |
    | TEXT               | ok           | ok                              |
    +--------------------+--------------+---------------------------------+
    

    So you have to pick your poison if you need to insert more data.

    {SQL Server} wasn't an option for me, e.g. because it doesn't support the DATE data type.

    So I stick with TEXT and hope that "ntext, text, and image data types will be removed in a future version of SQL Server." is just an empty threat.

    Necro edit: NVARCHAR(MAX) doesn't seem to have the 8000 (or 4000) character limit with the new ODBC drivers.

提交回复
热议问题