| title | DECOMPRESS (Transact-SQL) | Microsoft Docs | ||
|---|---|---|---|
| ms.custom | |||
| ms.date | 11/30/2015 | ||
| ms.prod | sql | ||
| ms.prod_service | database-engine, sql-database | ||
| ms.component | t-sql|functions | ||
| ms.reviewer | |||
| ms.suite | sql | ||
| ms.technology | t-sql | ||
| ms.tgt_pltfrm | |||
| ms.topic | language-reference | ||
| f1_keywords |
|
||
| helpviewer_keywords |
|
||
| ms.assetid | 738d56be-3870-4774-b112-3dce27becc11 | ||
| caps.latest.revision | 8 | ||
| author | edmacauley | ||
| ms.author | edmaca | ||
| manager | craigg |
[!INCLUDEtsql-appliesto-ss2016-asdb-xxxx-xxx-md]
Decompress input expression using GZIP algorithm. Result of the compression is byte array (VARBINARY(MAX) type).
Transact-SQL Syntax Conventions
DECOMPRESS ( expression )
expression
Is a varbinary(n), varbinary(max), or binary(n). For more information, see Expressions (Transact-SQL).
Returns the data type of varbinary(max) type. The input argument is decompressed using the ZIP algorithm. The user should explicitly cast result to a target type if needed.
The following example shows how to show compress data from a table:
SELECT _id, name, surname, datemodified,
CAST(DECOMPRESS(info) AS NVARCHAR(MAX)) AS info
FROM player;
The following example shows how to create a table to store decompressed data:
CREATE TABLE (
_id int primary key identity,
name nvarchar(max),
surname nvarchar(max),
info varbinary(max),
info_json as CAST(decompress(info) as nvarchar(max))
);