MyTechMantra.com
Connect With MyTechMantra.com

Like Us on Facebook    Follow Us on Twitter     Subscribe to our Feeds     Subscribe to NewsLetter
























SQL Server 2016: COMPRESS and DECOMPRESS T-SQL Enhancement in SQL Server 2016

Read Comments   |   Related Topic: TSQL Enhancements SQL Server 2016 > Next Topic: STRING_SPLIT and STRING_ESCAPE


Click here to read about new T-SQL enhancements in SQL Server 2016 from the beginning...

COMPRESS Function and DECOMPRESS Function in SQL Server 2016

SQL Server 2016 introduces two new system functions namely COMPRESS and DEOMPRESS.

COMPRESS Function: This function can be used to compress the input values using GZIP algorithm and the output will be of BYTE array of type VARBNARY(MAX).

DECOMPRESS Function: This function can be used to decompress the input value BYTE array using GZIP algorithm and it will return the BYTE array of type VARBINARY(MAX). To retrieve the actual value one would need to explicitly CAST result to a target type.

Example COMPRESS and DECOMPRESS function of SQL Server 2016

SELECT 
          'MyTechMantra' AS [Input Value To Compress]
          ,COMPRESS('SearchSQLServer') AS [Compressed Value]
          ,DECOMPRESS(COMPRESS('MyTechMantra')) AS [Decompressed Value]
          ,CAST(DECOMPRESS (COMPRESS ('MyTechMantra')) AS VARCHAR(MAX))AS [Derive Actual Input Value]
GO		

Related Tips

STRING_SPLIT and STRING_ESCAPE T-SQL Enhancement in SQL Server 2016
SERVERPROPERTY T-SQL Enhancement in SQL Server 2016
TRUNCATE TABLE WITH PARTITIONS T-SQL Enhancement in SQL Server 2016
DROP IF EXISTS T-SQL Enhancement in SQL Server 2016
ALTER TABLE WITH (ONLINE = ON | OFF) T-SQL Enhancement in SQL Server 2016

Thank you for taking your time to read this article. Let's be Connected....

Sign-up for Our Newsletter to Get Free SQL Server Tips and News to Build your Career

Like MyTechMantra on Facebook to get updates on What's Happening in SQL Server

Click the Next Page button to continue reading about New T-SQL enhancements in SQL Server 2016 and click on the Previous Page button to revise the previouly read topic.

Previous Page.. Next Page..




Learn More...





Last Updated On: May 15, 2016



Share this Article



Receive Free SQL Server Tips and Keep Learning
Get Free SQL Server Tips




Please leave your Valuable Comment or Let us know how this article helped you: