HASHBYTES (Transact-SQL) - SQL Server (2024)

  • Article

Applies to: HASHBYTES (Transact-SQL) - SQL Server (1) SQL Server HASHBYTES (Transact-SQL) - SQL Server (2) Azure SQL Database HASHBYTES (Transact-SQL) - SQL Server (3) Azure SQL Managed Instance HASHBYTES (Transact-SQL) - SQL Server (4) Azure Synapse Analytics HASHBYTES (Transact-SQL) - SQL Server (5) Analytics Platform System (PDW) HASHBYTES (Transact-SQL) - SQL Server (6) SQL analytics endpoint in Microsoft Fabric HASHBYTES (Transact-SQL) - SQL Server (7) Warehouse in Microsoft Fabric

Returns the MD2, MD4, MD5, SHA, SHA1, or SHA2 hash of its input in SQL Server.

HASHBYTES (Transact-SQL) - SQL Server (8) Transact-SQL syntax conventions

Syntax

HASHBYTES ( '<algorithm>', { @input | 'input' } ) <algorithm>::= MD2 | MD4 | MD5 | SHA | SHA1 | SHA2_256 | SHA2_512 

Arguments

<algorithm>
Identifies the hashing algorithm to be used to hash the input. This is a required argument with no default. The single quotation marks are required. Beginning with SQL Server 2016 (13.x), all algorithms other than SHA2_256, and SHA2_512 are deprecated.

@input
Specifies a variable containing the data to be hashed. @input is varchar, nvarchar, or varbinary.

'input'
Specifies an expression that evaluates to a character or binary string to be hashed.

The output conforms to the algorithm standard: 128 bits (16 bytes) for MD2, MD4, and MD5; 160 bits (20 bytes) for SHA and SHA1; 256 bits (32 bytes) for SHA2_256, and 512 bits (64 bytes) for SHA2_512.

Applies to: SQL Server 2012 (11.x) and later

For SQL Server 2014 (12.x) and earlier, allowed input values are limited to 8000 bytes.

Return Value

varbinary (maximum 8000 bytes)

Remarks

Consider using CHECKSUM or BINARY_CHECKSUM as alternatives to compute a hash value.

The MD2, MD4, MD5, SHA, and SHA1 algorithms are deprecated starting with SQL Server 2016 (13.x). Use SHA2_256 or SHA2_512 instead. Older algorithms will continue working, but they will raise a deprecation event.

Examples

Return the hash of a variable

The following example returns the SHA2_256 hash of the nvarchar data stored in variable @HashThis.

DECLARE @HashThis NVARCHAR(32); SET @HashThis = CONVERT(NVARCHAR(32),'dslfdkjLK85kldhnv$n000#knf'); SELECT HASHBYTES('SHA2_256', @HashThis); 

Return the hash of a table column

The following example returns the SHA2_256 hash of the values in column c1 in the table Test1.

CREATE TABLE dbo.Test1 (c1 NVARCHAR(32)); INSERT dbo.Test1 VALUES ('This is a test.'); INSERT dbo.Test1 VALUES ('This is test 2.'); SELECT HASHBYTES('SHA2_256', c1) FROM dbo.Test1; 

Here is the result set.

------------------------------------------- 0x741238C01D9DB821CF171BF61D72260B998F7C7881D90091099945E0B9E0C2E3 0x91DDCC41B761ACA928C62F7B0DA61DC763255E8247E0BD8DCE6B22205197154D (2 row(s) affected) 

See Also

Choose an Encryption AlgorithmCHECKSUM_AGG (Transact-SQL)CHECKSUM (Transact-SQL)BINARY_CHECKSUM (Transact-SQL)

HASHBYTES (Transact-SQL) - SQL Server (2024)
Top Articles
Réinitialisation du FortiToken pour l'authentification à deux facteurs (2FA)
D'accord, je vais écrire un article sur le changement d'échelles et d'axes sur les graphiques de trading. Voici le contenu :
No Hard Feelings Showtimes Near Metropolitan Fiesta 5 Theatre
Oldgamesshelf
Lifewitceee
Belle Meade Barbershop | Uncle Classic Barbershop | Nashville Barbers
Find All Subdomains
Google Jobs Denver
Georgia Vehicle Registration Fees Calculator
Craigslist Furniture Bedroom Set
Trade Chart Dave Richard
Optimal Perks Rs3
The Wicked Lady | Rotten Tomatoes
Snowflake Activity Congruent Triangles Answers
Wgu Admissions Login
Illinois Gun Shows 2022
979-200-6466
Moviesda3.Com
What is Rumba and How to Dance the Rumba Basic — Duet Dance Studio Chicago | Ballroom Dance in Chicago
Billionaire Ken Griffin Doesn’t Like His Portrayal In GameStop Movie ‘Dumb Money,’ So He’s Throwing A Tantrum: Report
Boston Gang Map
St Maries Idaho Craigslist
Kylie And Stassie Kissing: A Deep Dive Into Their Friendship And Moments
White Pages Corpus Christi
Mccain Agportal
Fsga Golf
Lisas Stamp Studio
Two Babies One Fox Full Comic Pdf
Jeff Nippard Push Pull Program Pdf
Arrest Gif
Mdt Bus Tracker 27
As families searched, a Texas medical school cut up their loved ones
3 Ways to Drive Employee Engagement with Recognition Programs | UKG
Fuse Box Diagram Honda Accord (2013-2017)
Shiny Flower Belinda
What we lost when Craigslist shut down its personals section
Gopher Carts Pensacola Beach
Valley Craigslist
Imagetrend Elite Delaware
ATM, 3813 N Woodlawn Blvd, Wichita, KS 67220, US - MapQuest
Busted! 29 New Arrests in Portsmouth, Ohio – 03/27/22 Scioto County Mugshots
Fbsm Greenville Sc
The Pretty Kitty Tanglewood
Admissions - New York Conservatory for Dramatic Arts
Myql Loan Login
Anya Banerjee Feet
Timberwolves Point Guard History
Tsbarbiespanishxxl
Underground Weather Tropical
Glowforge Forum
Karen Kripas Obituary
Acellus Grading Scale
Latest Posts
Article information

Author: Twana Towne Ret

Last Updated:

Views: 5802

Rating: 4.3 / 5 (64 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Twana Towne Ret

Birthday: 1994-03-19

Address: Apt. 990 97439 Corwin Motorway, Port Eliseoburgh, NM 99144-2618

Phone: +5958753152963

Job: National Specialist

Hobby: Kayaking, Photography, Skydiving, Embroidery, Leather crafting, Orienteering, Cooking

Introduction: My name is Twana Towne Ret, I am a famous, talented, joyous, perfect, powerful, inquisitive, lovely person who loves writing and wants to share my knowledge and understanding with you.