Skip to content

Latest commit

 

History

History
75 lines (56 loc) · 2.42 KB

decompress-transact-sql.md

File metadata and controls

75 lines (56 loc) · 2.42 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic f1_keywords helpviewer_keywords dev_langs monikerRange
DECOMPRESS (Transact-SQL)
DECOMPRESS (Transact-SQL)
markingmyname
maghan
10/11/2018
sql
t-sql
reference
DECOMPRESS
DECOMPRESS_TSQL
DECOMPRESS function
TSQL
= azuresqldb-current || = azuresqldb-mi-current || >= sql-server-2016 || >= sql-server-linux-2017 || = azuresqledge-current || = azure-sqldw-latest

DECOMPRESS (Transact-SQL)

[!INCLUDE sqlserver2016-asdb-asdbmi-asa]

This function will decompress an input expression value, using the GZIP algorithm. DECOMPRESS will return a byte array (VARBINARY(MAX) type).

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

Syntax

DECOMPRESS ( expression )  

Arguments

expression
A varbinary(n), varbinary(max), or binary(n) value. See Expressions (Transact-SQL) for more information.

Return Types

A value of data type varbinary(max). DECOMPRESS will use the GZIP algorithm to decompress the input argument. The user should explicitly cast result to a target type if necessary.

Remarks

Examples

A. Decompress Data at Query Time

This example shows how to return compressed table data:

SELECT _id, name, surname, datemodified,  
             CAST(DECOMPRESS(info) AS NVARCHAR(MAX)) AS info  
FROM player;  

B. Display Compressed Data Using Computed Column

Note

This example does not apply to Azure Synapse Analytics.

This example shows how to create a table for decompressed data storage:

CREATE TABLE example_table (  
    _id INT PRIMARY KEY IDENTITY,  
    name NVARCHAR(max),  
    surname NVARCHAR(max),  
    info VARBINARY(max),  
    info_json as CAST(DECOMPRESS(info) as NVARCHAR(max))  
);  

See Also

String Functions (Transact-SQL)
COMPRESS (Transact-SQL)