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
6
votes
2 answers

How to compare varbinary in where clause in SQL Server

I want to compare varbinary type with byte array. I have tried so far: DECLARE @data AS NVARCHAR(MAX)='4283' Select * from table1 Where bindayData=CAST(@data AS VARBINARY) But this does not work. I note one strange behavior of this: when I…
Naresh Goradara
  • 1,896
  • 2
  • 30
  • 41
6
votes
3 answers

Ad-hoc retreival of data from SQL Server varbinary column

I would like to retreive some binary data from a varbinary(max) column in a SQL Server database for debugging purposes. What is the easiest way to get this data into a local binary file, preferably without having to write a throw-away console…
Daniel Fortunov
  • 43,309
  • 26
  • 81
  • 106
6
votes
2 answers

Save UUID as varbinary(16) in MySQL causes com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'ID' at row 1

I have a field id defined as below. It's varbinary(16) in database, when i am inserting a new record through JPA, i got "com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'ID' at row 1". What am I doing…
topcan5
  • 1,511
  • 8
  • 30
  • 54
6
votes
2 answers

Is there a way to turn sys.fn_varbintohexstr result back to varbinary?

Is there a function in SQL Server to do that? to reverse sys.fn_varbintohexstr?
user1617237
  • 143
  • 1
  • 3
  • 11
6
votes
1 answer

SQL Convert unicode encoded varbinary to string

Ok, i have to export REG_BINARY values and store them in SQL and later i need to convert these values to a string.. What i have: in c# i read the REG_BINARY to a Byte[] data type like: RegistryKey rk = Registry.CurrentUser.OpenSubKey... byte[]…
Christian Casutt
  • 2,334
  • 4
  • 29
  • 38
5
votes
2 answers

SQL Query to store text data in a Varbinary(max)

Is there a way to make a varbinary accept text data in SQL Server? Here is my situation. I have a fairly large amount of XML that I plan on storing in a "zipped" format. (This means a Varbinary.) However, when I am debugging, I want to be able to…
Vaccano
  • 78,325
  • 149
  • 468
  • 850
5
votes
1 answer

Passing VARBINARY to stored procedure

I have some source data that is formatted as ASCII hexadecimal. I need to get it into a SQL database in VARBINARY fields. I've reduced the problem to the bare minimum to illustrate what I'd like to do. I have a stored procedure: CREATE PROCEDURE…
BillP3rd
  • 1,009
  • 1
  • 9
  • 21
5
votes
4 answers

Convert varbinary back to .txt file

I have a database (SQL 2008) where I store file's in. These are saved as a varbinary(max) type. Now I need to get the .txt file again so I can loop through the contents of the file like i used to do with StreamReader. while ((line = file.ReadLine())…
Robin
  • 89
  • 1
  • 2
  • 9
5
votes
1 answer

How can I hash a string to a bigint in presto?

I have a long string and I would like to semi-uniquely represent it as a bigint. Ideally I'd just take the hash, but presto hash functions seem to want to return "varbinary", and I can't find a function to convert a varbinary into a bigint. If I…
erbert
  • 153
  • 1
  • 4
5
votes
3 answers

SQL Server performance: 50 columns vs single binary/varbinary

Is it possible to improve SQL Server 2008 R2 (and newer) insert performance by replacing (say) 50 float columns with a single binary(n) (n being 50 x 4)? I would presume that using a fixed size binary(n) should improve performance (amount of data…
Lou
  • 4,244
  • 3
  • 33
  • 72
5
votes
2 answers

What does VARBINARY(MAX) mean?

I'm trying to port a MSSQL database over to MariaDB and I've encountered a table creation using varbinary(max): `definition` VARBINARY(max) NULL DEFAULT NULL What would this actually do and is there an equivalent type definition in MariaDB that…
SPlatten
  • 5,334
  • 11
  • 57
  • 128
5
votes
3 answers

How can I extract the value of a varbinary(max) column?

I have a varbinary(max) column that is storing images in an SQL database. I am working on a newdb script, where an application creates a new instance of the db and populates a few of the tables. One of those tables I am working on is initializing…
James Madison
  • 337
  • 1
  • 4
  • 17
5
votes
2 answers

SQL Server string to varbinary conversion

Ok, the problem is that there's a merger or join that needs to be done on 2 tables. One has file content stored as an [image] type or varbinary(max), the other has the file content stored as a hex string. if I upload the same content into both…
Matthew Weir
  • 186
  • 1
  • 1
  • 9
5
votes
1 answer

NHibernate : Store VARBINARY to MAX

I am using following mapping to store a Serializable object to SQL Server 2008:
Tapas Bose
  • 28,796
  • 74
  • 215
  • 331
4
votes
1 answer

TSQL vbinary bitmasking with varbinary right hand side operator

I am looking for some hints or tricks for this design challenge I am up against: I have a need to bitmask two of the same size varbinary fields stored in the database. Just to clarify, no this is not a "permissions table" or anything. I would…
1 2
3
27 28