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
3 answers

Django: How to model a MySQL VARBINARY HEX Field?

I am trying to model a VARBINARY MySQL field in Django v1.1.1. The binary field stores a hexadecimal representation of data (i.e. one would use INSERT INTO test(bin_val) VALUES X'4D7953514C') Reading the Django documentation[1] I came up with this…
the_void
  • 5,512
  • 2
  • 28
  • 34
3
votes
1 answer

SQL Server Varchar to VarBinary Conversion

I have to insert the string "johnmelling" value into a table which has the column as [USERPASS] varbinary NOT NULL. Please could any one suggest me, what would be the best conversion to insert "johnmelling"? I tried to to insert as below, Insert…
user2124664
  • 35
  • 1
  • 1
  • 5
2
votes
1 answer

Dealing with a varbinary field in VB.NET

A partner of ours is making a call to a web service that includes a parameter called token. Token is the result of an MD5 hash of two numbers, and helps us authenticate that the user using our partners system. Our partner asks the user for two…
Kyle
  • 963
  • 3
  • 16
  • 32
2
votes
1 answer

Write query for inserting varbinary value in PostgreSQL

What is the syntax in PostgreSQL for inserting varbinary values? SQL Server's syntax using a constant like 0xFFFF, it didn't work.
kilonet
2
votes
3 answers

Handling hashed passwords stored as varbinary in SQL Server and classic ASP

All, Sorry in advance - I'm a novice in most of the topics below (SQL, ASP). Anyway... I've got a pretty simple web app that requires users to log in with a user name and password. The front end creates a salted SHA1 hash of the password, and posts…
mattstuehler
  • 9,040
  • 18
  • 78
  • 108
2
votes
1 answer

Correctly store and retrieve PDF file using SQL database with .NET

I have created a Web Application which sends PDF files to an SQL database table to later be loaded and sent via Email. Currently my code works and PDF file is being sent in Email, however once opening the PDF all is shown as expected except for the…
2
votes
1 answer

Sanitizing MSSQL (&/OR Putting HEX into a TEXT Column)

Overview I'm in need of a way to properly sanitize my MSSQL data. We all know addslashes() and htmlentities() doesn't cut it. Attempted Solution & Problem After research, I found this thread here on SO. It worked great, until I needed to insert into…
ShaneC
  • 2,376
  • 4
  • 19
  • 27
2
votes
1 answer

SQL: Selecting from a varbinary column ignores trailing zeros

I have a varbinary(16) column in a MSSQL database. One of the possible contents of this column is a PIN. A PIN can have a variable number of digits: "1234" or "12340" for example. In the PIN case, every digit is represented as a single byte, so…
Powerslave
  • 531
  • 2
  • 7
  • 24
2
votes
1 answer

Error writing >4000 bytes to varbinary(max) via linq-to-sql classes

The type of my database column is varbinary(max), (sql server 2008). Linq to Sql Classes (vs 2010, fx4) has generated this code for me: [global::System.Data.Linq.Mapping.ColumnAttribute (Storage="_Raw", DbType="VarBinary(MAX)",…
wozza
  • 255
  • 2
  • 7
2
votes
1 answer

Perl DBI / MS ODBC Driver (LinuxL:RHEL) / SQL-Server: How to insert/update BLOB varbinary(max) data?

New to SQL-Server. I'm attempting to load a pdf to a SQL-Server table (data type varbinary(max)) via PERL/MS ODBC driver/DBD::ODBC using the following (simplified) code: use DBI qw(:sql_types); open my $pdfFH, "test.pdf"; my @pdf = <$pdfFH>; close…
cgeen
  • 23
  • 3
2
votes
1 answer

Saving XML from a string to a varbinary column in Sql Server 2005 .NET

Using .NET (in an SSIS package): I've got an XML string in memory which I need to save to a varbinary column in Sql Server, as an XML file. It seems like I should be able to avoid actually saving a .xml file to disk, and do all of this in memory,…
Joel
  • 2,217
  • 5
  • 34
  • 45
2
votes
3 answers

XML in C# to varbinary column in SQL

I have an XmlDocument object that I load from a file. XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load("C:\\myxml.txt"); I need to convert this XML Document to a format that is compatible with varbinary in a SQL table. How can I achieve this?
jkh
  • 3,618
  • 8
  • 38
  • 66
2
votes
1 answer

How to composite two varbinaries

I have two varbinary masks: @mask1 = 0x0000000000000001 @mask65 = 0x7FFFFFFFFFFFFFFF0000000000000003 I have to 1) composite them to get something like this @mask_composite = @mask1 | @mask65 2) check @mask_composite & @mask2 > 0 How can I do…
garik
  • 5,669
  • 5
  • 30
  • 42
2
votes
2 answers

How to dump all of our images from a VARBINARY(MAX) field in SQL Server 2008 to the filesystem?

I have a table which has an IDENTITY field and a VARBINARY(MAX) field in it. Is there any way I could dump the content of each VARBINARY(MAX) field to the filesystem (eg. c:\temp\images)? Table schema: PhotoId INTEGER NOT NULL IDENTITY Image…
Pure.Krome
  • 84,693
  • 113
  • 396
  • 647
2
votes
2 answers

T-SQL DecryptByKey returns NULL with Column Value, but not with Column Name

I have an encrypted varbinary(MAX) field in my DB called ACCT_FName_encrypt. I can successfully decrypt this field with: CONVERT(nvarchar(MAX), DecryptByKey(ACCT_FName_encrypt)) AS 'ACCT_FName_Denc' But if I try to decrypt the actual value from…