Skip to content

Data type for SQL Server for DbType.AnsiString #8

@beppler

Description

@beppler

On DbTypes x SqlServer is documented that the types generated for DbType.AnsiString are the following:

  • char(255) if precision is not specified
  • char(n) if precision is between 1 and 255
  • text if precision is between 256 and 65535
  • mediumtext if precision is between 65536 and 16777215

Based on SQL Server Data Type Mappings the type used for AnsiString should be:

  • varchar(255) if precision is not specified (to remain compatible with previous behavior)
  • varchar(n) for precision between 1 and 8000
  • varchar(max) for precision bigger than 8000

The mediumtext datatype does not exist on SQL Server and text datatype is deprecated, but should be used if SQL Server is version 2005 or older.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions