Binary Data Types in SQL Server

In sql, binary data types are used to store any kind of binary data like images, word files, text files, etc. in table. In binary data types we have an option like allow users to store fixed length or variable length of bytes based on requirements.

 

In sql, we have a different type of binary data types available, those are

 

  • binary datatype
  • varbinary datatype
  • varbinary(max) datatype

SQL Binary DataType

In sql, we can use binary datatype whenever the size of data entries are consistent.

SQL varbinary DataType

In sql, we can use varbinary datatype whenever the size of data entries are considerably varies.

SQL varbinary(max) DataType

In sql, we can use varbinary(max) datatype whenever the size of data entries exceeds 8000 bytes.

 

Please check following table for more details regarding binary data types in sql server.

 

Data TypeDescriptionStorage
binary(n) It’s fixed length binary data and we can store maximum 8000 bytes Based on defined size
varbinary It’s variable length binary data and we can store maximum 8000 bytes Based on number of bytes
varbinary(max) It’s variable length character string and we can store maximum 2GB data Based on number of bytes

Topics Covered