Skip to content

Data type for SQL Server for DbType.Binary #12

@beppler

Description

@beppler

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

  • binary

Based on , if the size of binary is not specifed the declaration is same as binary(1)

Also, based on SQL Server Data Type Mappings the type used for DbType.Binary could be binary, varbinary or image.

SQL Server image datatype is deprecated, but should be used for SQL Server 2005 or older.

We can not know only based on enumeration if user want to use binary or varbinary so a decision must be made between one of the following options:

Use binary:

  • binary if precision is not specified (to remain compatible with previous behavior)
  • binary(n) for precision between 1 and 8000
  • throw an exception if precison is greate than 8000

Use varbinary:

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

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