In SQL, binary data types are used to store any kind of binary data like images, word files, text files, etc. in the table. In binary data types, we have an option like allowing 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
In SQL, we can use binary datatype whenever the size of data entries are consistent.
In SQL, we can use varbinary datatype whenever the size of data entries are considerably varies.
In SQL, we can use varbinary(max) datatype whenever the size of data entries exceeds 8000 bytes.
Please check the following table for more details regarding binary data types in SQL Server.
Data Type | Description | Storage |
---|---|---|
binary(n) | It’s fixed-length binary data and we can store maximum 8000 bytes | Based on the 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 a variable-length character string and we can store maximum 2GB data | Based on the number of bytes |