Questions tagged [varbinary]

varbinary is the SQL Server datatype used to hold variable-length binary data

SQL Server's varbinary datatype is declared with a length specification in the CREATE TABLE statement:

CREATE TABLE tablename (..., colName varbinary(n), ...)

where n is the maximum size of the column in bytes (limited to a maximum of 8000), or the word MAX if more than 8000 bytes might need to be stored. (The absolute maximum size is approximately 2gb as of this writing; consult SQL Server documentation for the exact current maximum.)

For more information, see this entry in the SQL Server online documentation.

411 questions
3
votes
4 answers

ASP.NET Store uploaded file sql server table

How do you store a file that was uploaded by an ASP.net webform into a sql server 2005 varbinary(max) field? Here is what I have so far: protected void btnUpload_Click(object sender, EventArgs e) { for (int i = 0; i < Request.Files.Count; i++) …
Ronnie Overby
  • 45,287
  • 73
  • 267
  • 346
3
votes
2 answers

SQL Server 2005: Replication, varbinary

Scenario In our replication scheme we replicate a number of tables, including a photos table that contains binary image data. All other tables replicate as expected, but the photos table does not. I suspect this is because of the larger amount of…
brad
  • 73,826
  • 21
  • 73
  • 85
3
votes
1 answer

Converting image files to VARBINARY(max) in flutter

I need to store images that are captured using "image picker" in a SQL server database final image = await ImagePicker().pickImage(source: ImageSource.camera, imageQuality: 25); now, I know that the images should be stored in a "VARBINARY"…
Ramy Gomaa
  • 33
  • 5
3
votes
1 answer

Assigning an empty binary value to a varbinary(MAX) column creates a column 8000 bytes long

I have a table with a varbinary(max) column, i am trying to assign to that column a zero-lengh binary buffer, but instead of getting a zero-length value in the table, i am getting an 8000 bytes long value filled with zeros: * the dataSize column in…
Amit Bens
  • 1,315
  • 3
  • 12
  • 20
3
votes
1 answer

How do I use varbinary if I don't know the length of my text

I want to encrypt text using AES in mysql, but I have a small problem, because you need to use varbinary to store these. Some of my datatypes are varchar and yes I can probably work out the length of my varbinary for these. However for my address…
Thomas Williams
  • 1,528
  • 1
  • 18
  • 37
3
votes
0 answers

MySQL to MSSQL via linked server: blob to varbinary

I have a mysql database that I need to be imported into sql server via a linked server. Two of the mysql columns are blob and mediumblob. The columns in mssql are varbinary(max). When I execute a query at the linked server, I get the error: OLE DB…
Roger
  • 2,063
  • 4
  • 32
  • 65
3
votes
1 answer

getting Stream in and out of VarBinary(MAX) column? (SQL Server)

I have some data that I am serializing. I need to save and restore this from a VarBinary column using ADO.NET (also using Enterprise Library) under .Net 3.5 (not 4.0 yet). The only interface I seem to be able to find and get working is by using a…
Chris
  • 959
  • 2
  • 9
  • 20
3
votes
1 answer

Adding a 'varbinary' MySQL field type with Phinx Migrate

I'm trying to create a migration in Phinx which will create a varbinary type field in a MySQL DB to store an ip_address. This is what I have: $table = $this->table('my_table'); $table->addColumn('ip_address', 'varbinary', ['after' => 'id', 'limit'…
Nathan Pitman
  • 2,286
  • 4
  • 30
  • 46
3
votes
2 answers

Can I set 2 MB for maximum size of varbinary?

As far as I know the maximum value you can define "manually" is 8000 -> varbinary(8000) which, as far as I know, means 8000 bytes -> 7,8125 KByte. Is it possible to set max to 2 MB? Something ike varbinary(2097152), or shall I set it to…
fishmong3r
  • 1,414
  • 4
  • 24
  • 51
3
votes
1 answer

Primary Key - VARBINARY or BLOB or VARCHAR for UUID primary key

I am using UUID as the primary key in one of the tables. What are the pros-cons of having this field as a varchar/varbinary/blob?
Swati
  • 41
  • 1
  • 3
3
votes
1 answer

Is it correct to use -1 as a size for an output SqlParameter to retrieve a VARBINARY(max) value?

I have a stored procedure with an OUTPUT parameter of the varbinary(MAX) type: ALTER PROCEDURE [dbo].[StoredProcedure1] ... @FileData varbinary(MAX) OUTPUT AS ... I don't know what would be the actual size of the returned data, so I can't use…
Alexander Abakumov
  • 13,617
  • 16
  • 88
  • 129
3
votes
1 answer

Are there performance problems in querying non varbinary(max) fields in a table containing varbinary(max) data?

I created a table to insert all the documents of my application. It is a simple table (let's call it DOC_DATA) that has 3 fields: DOC_ID, FileSize, Data. Data is varbinary(max). I then have many tables (CUSTOMERS_DOCUMENTS, EMPLOYEES_DOCUMENTS, ...)…
UnDiUdin
  • 14,924
  • 39
  • 151
  • 249
3
votes
3 answers

System.OutOfMemoryException - when Entity Framework is querying a too big data of Varbinary type

I'm trying to query a varbinary column that contain a file (1,2 Gb). I'm using Entity Framework. See below: Database to test CREATE TABLE [dbo].[BIGDATA] ( [id] [bigint] IDENTITY(1,1) NOT NULL, [BIGDATA] [varbinary](max) NULL, …
user3812703
3
votes
1 answer

Can I return a byte array from a SQL Server VarBinary column using a parameterized query?

I wrote a small VBA procedure to test uploading and downloading of files as binary data into and out of a VarBinary column in SQL Server using ADO. The upload process appears to work, but I cannot get the download process to work. I believe the…
Kuyenda
  • 4,529
  • 11
  • 46
  • 64
3
votes
3 answers

Hexadecimal valued string to varbinary SQL Server 2008

I have a string with a hexadecimal value, as an example, like so: "AD5829FC..." which is a varbinary I took and saved in hexadecimal to a text file. The thing is, I need to get this back to a varbinary by running an insert query through C# and SQL…
rdelfin
  • 819
  • 2
  • 13
  • 31