Export (0) Print
Expand All
Expand Minimize
8 out of 28 rated this helpful - Rate this topic

binary and varbinary (Transact-SQL)

Binary data types of either fixed length or variable length.

binary [ ( n ) ]

Fixed-length binary data with a length of n bytes, where n is a value from 1 through 8,000. The storage size is n bytes.

varbinary [ ( n | max) ]

Variable-length binary data. n can be a value from 1 through 8,000. max indicates that the maximum storage size is 2^31-1 bytes. The storage size is the actual length of the data entered + 2 bytes. The data that is entered can be 0 bytes in length. The SQL-2003 synonym for varbinary is binary varying.

When n is not specified in a data definition or variable declaration statement, the default length is 1. When n is not specified with the CAST function, the default length is 30.

Use binary when the sizes of the column data entries are consistent.

Use varbinary when the sizes of the column data entries vary considerably.

Use varbinary(max) when the column data entries exceed 8,000 bytes.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.