I want to store an array of bytes in my SQL Server. What datatype, or pre INSERT manipulation would you suggest to store these?
I wouldn’t expect these byte[] to exceed 1024 in length.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
varbinary(1024)is what you’re looking for.There are three types in SQL Server for binary value storage:
binary(n)for fixed-length binary data of lengthn. Length can be1to8000.varbinary(n)for variable-length binary data maximum lengthn. Maximum length can be1to8000.Above types will be stored in the row data itself.
varbinary(max)which is used to store large binary values (BLOBs) up to 2GB. The actual value is stored in a separate location if it’s larger than 8000 bytes and just a pointer is stored in the row itself. This type is available since SQL Server 2005.imagedata type was used to store BLOBs prior to SQL Server 2005. It’s deprecated in favor ofvarbinary(max). The storage location forimageis always outside data row.