Skip to content

Latest commit

 

History

History
73 lines (58 loc) · 2.34 KB

decompress-transact-sql.md

File metadata and controls

73 lines (58 loc) · 2.34 KB
title ms.custom ms.date ms.prod ms.prod_service ms.reviewer ms.suite ms.technology ms.tgt_pltfrm ms.topic f1_keywords helpviewer_keywords ms.assetid caps.latest.revision author ms.author manager
DECOMPRESS (Transact-SQL) | Microsoft Docs
11/30/2015
sql
database-engine, sql-database
sql
t-sql
language-reference
DECOMPRESS
DECOMPRESS_TSQL
DECOMPRESS function
738d56be-3870-4774-b112-3dce27becc11
8
MashaMSFT
mathoma
craigg

DECOMPRESS (Transact-SQL)

[!INCLUDEtsql-appliesto-ss2016-asdb-xxxx-xxx-md]

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

Topic link icon 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 ZIP 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

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)