HASHBYTES()
HASHBYTES() is a SQL function in the SQL Server Specific category. SQL Server: returns the hash of input using MD2, MD4, MD5, SHA, SHA1, SHA2_256, SHA2_512. The syntax is HASHBYTES('algorithm', input). It accepts see syntax. It returns binary hash value. A typical example: SELECT HASHBYTES('SHA2_256', 'password123'); -- 0xA665A45... (32 byte binary hash) -- For password hashing: CREATE TABLE users (username VARCHAR(100), password_hash VARBINARY(32)); INSERT INTO users VALUES ('alice', HASHBYTES('SHA2_256', CONCAT('salt', 'secret'))); -- PostgreSQL equivalent: -- SELECT encode(sha256('password'::bytea), 'hex'); A close relative is OUTPUT Clause, which sQL Server: returns values from DML statements (like PostgreSQL RETURNING). A close relative is STUFF(), which sQL Server: deletes a specified length of characters from a string and inserts another string at the start position. A close relative is FOR XML PATH, which sQL Server: converts query results to XML format. Commonly used for string concatenation hack. More about this category: SQL Server-specific features — T-SQL, OUTPUT, TOP, PIVOT, STUFF, FOR XML.