binary and varbinary (Transact-SQL) Home
SQL Server 2008 Books Online (October 2009)
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 ANSI SQL synonym for varbinary is binary varying.

Remarks

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.

See Also

Reference

CAST and CONVERT (Transact-SQL)
Data Types (Transact-SQL)

Other Resources

Data Type Conversion (Database Engine)

Help and Information

Getting SQL Server 2008 Assistance
Community Content

varbinary replaces image
Added by:Doug V
Note that Microsoft states the image data type is deprecated and will be dropped in a future release of SQL Server. varbinary(max) should suffice as a replacement.
© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View