1

I want to perform a 'SELECT' statement with a byte array (binary) parameter as a condition. I tried to google it, but didn't find anything useful.

In general, I keep information of files in the database. one of the properties is the file's hash (binary).

I want to give a hash to the SELECT statement, and get all rows with the same hash value.

2
  • can you post the code you are trying to run? And tell us what SQL database you are using. Commented Jun 2, 2010 at 11:16
  • I'm using sql server ce 3.1. I want something like: Select * from BL_FILES where HASH = [byte array] Currently i'm retrieving all files and performing the comparison using my code, but I want to implement a more elegant solution Commented Jun 2, 2010 at 11:35

1 Answer 1

3
DECLARE @PARA BINARY
SET @PARA = 0X000
SELECT @PARA
SELECT 
    *
FROM
    [Table]
WHERE
    PARA = @PARA
Sign up to request clarification or add additional context in comments.

2 Comments

Is there's anyway for doing this without 'DECLARE'? i'm using SqlServerCe which only allows one statement per command
Thanks, I solved it using: "SELECT * FROM BL_FILES WHERE Hash = 0x + BitConverter.ToString(byte[]).Replace("-",string.Empty)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.