Questions tagged [hashbytes]

A hashing function within the Microsoft Transact-SQL Database Engine.

A hashing function within the Microsoft Transact-SQL Database Engine which supports the following algorithms:

  • MD2
  • MD4
  • MD5
  • SHA
  • SHA1
  • SHA2_256
  • SHA2_512

Resources

62 questions
1
vote
1 answer

MySQL, how do I hash a column from on table and move it to another table?

I have a table with a list of credit card numbers and I would like to hash those numbers and add them to another column in the same table. I am able to Hash the card numbers: SELECT HASHBYTES('SHA1', PlainText) FROM CreditCard and I get a good…
1
vote
1 answer

Storing HASHBYTES output in NVARCHAR vs BYTES

I am going to create: a table for storing IDs and unique text values (which are expected to be large) a stored procedure which will have a text value as input parameter (it will check if the value exists in the above table and return…
gotqn
  • 42,737
  • 46
  • 157
  • 243
1
vote
1 answer

SQL Server 2014: HASHBYTES returning different value for same string

I am working with a CSV file of addresses that get uploaded to an FTP site on a daily basis. The address records consist of Address_Line1, Address_Line2, City, State, Zip_Code, and Country. There are multiple duplicate addresses in the CSV. My task…
EvanMPW
  • 351
  • 1
  • 6
  • 15
1
vote
1 answer

BIML code to generate a HASHBYTE MD5 column

I am getting an error with the following section of the code which deal with the HASHBYTE logic.
Aarion
  • 59
  • 9
0
votes
1 answer

Converting Varbinary to Char and again to Varbinary for Primary key

I came across a sql code, which creates primary keys with hashbytes function and md5 algorithm. The code looks like this: SELECT CONVERT(VARBINARY(32), CONVERT( CHAR(32), HASHBYTES('MD5', …
ulie
  • 15
  • 3
0
votes
1 answer

Unique HASHID with 20 characters limit using SQL Server

A code has a 20 character limit but it needs to be unique. To make it unique there are 3 parts combinations of these values will exceed the 20 characters limits, more like 40 – 50 size. So the idea is to generate some type of unique ID based on that…
ElevenCent
  • 19
  • 4
0
votes
2 answers

Need SQL Server HASHBYTES SHA1 output using Snowflake SHA1/standard SHA1 function

We are migrating SQL server commands/scripts to Snowflake SQL and got stuck with this particular query. We have been using the HASHBYTES function in SQL Server for hashing this string to the SHA1 algorithm. Unfortunately, the output of our SQL…
0
votes
1 answer

How do I compare a TEXT field between two different databases (MySQL, SQL SERVER) with a hash?

I'm attempting to quickly compare large data in two separate applications (one on MySQL, the other on SQL SERVER). the myData field is a TEXT field in both databases, and I want to see if the value of this field has changed between them (myData can…
NEW2WEB
  • 503
  • 2
  • 8
  • 22
0
votes
0 answers

Creating a hash key to serve as unique key

I have a very large table that has duplicate name and address information. This table feeds a process which performs a task and appends results back to the table. I'd like to reduce the volume of what's fed into this process by creating a hash key…
tad
  • 23
  • 5
0
votes
0 answers

Get short hash value from the HASHBYTES('SHA1', text) independent on the SQL Server version?

For the purpose of getting the content-derived key of a longer text, I do calculate HASHBYTES('SHA1', text). It returns 20 bytes long varbinary. As I know the length of the result, I am storing it as binary(20). To make it shorter (to be used as a…
pepr
  • 20,112
  • 15
  • 76
  • 139
0
votes
1 answer

Convert HASBYTES function output to CHAR

I know that the best data type for storing output of the HASHBYTES function is BINARY/VARBINARY, but we want to store it as CHAR as it is suggested by DataVault best practices, moreover not all tolls support keys of BINARY types, for example…
Dmitrij Kultasev
  • 5,447
  • 5
  • 44
  • 88
0
votes
1 answer

Is there an equivalent of T-SQL's HASHBYTES('SHA1', VARBINARY(MAX)) in Java?

I am using org.apache.commons.codec.digest.DigestUtils library to calculate the SHA1 hash in Java. DigestUtils.sha1Hex("0x808204E039EFB76D96D3780BB507674"). Unfortunately, this doesn't give the same result as the below SQL statement? select…
0
votes
1 answer

hashbytes equivalent in mysql when working with none english text

When I am working with none-English characters the generated hash is not the same but otherwise, everything is fine. does anyone have a solution to get the same result? MYSQL SELECT MD5( 'سلام') ------------- result:…
Hooman Nemati
  • 97
  • 1
  • 7
0
votes
1 answer

Insert hashbytes Incorrect syntax near 'MD5'

I'm using SQL Server 2014. As part of a larger task, I need to detect updates etc from a table so am implementing Hashbytes. The Hasbytes field is defined as varbinary(MAX). This is my SQL: INSERT INTO tbl_People SELECT id, Name, …
Michael
  • 2,507
  • 8
  • 35
  • 71
0
votes
1 answer

SQL Query return different result for parameter vs hardcoded value passed to HashBytes Function

I need to pass values through a prameter to a HashBytes Function. When I hardcode the values, and when I use a parameter, the results are different: I've tried to play with VarChar vs nVarChar I've tried to play with CHAR(13) and/or CHAR(10) I've…