Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Compression and Decompression in SQL Server 2016

    • 0
    • 2
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 253
    Comment on it

    In the upcoming version of SQL 2016 a new component of COMPRESS and DECOMPRESS T-SQL functions is added. SQL Server 2016 provides built in functions for compression and decompression.The COMPRESS and DECOMPRESS functions can store and retrieve data using the GZIP compression algorithm. Like you would expect the COMPRESS function compressed data before it is stored in a column or variable. It returns a binary data. The DECOMPRESS function is used to decompress the binary data and return the decompressed version of that data. We need to cast a binary data to text if we compressed the text data.

    - CREATE TABLE Person (_id int primary
    key identity,name
    varchar(max),surname
    varchar(max),infobinary(max))
    

    Now, we can directly load compressed information into this column.

    -INSERT INTO People (name, surname,
    info)  SELECT FirstName, LastName,
    COMPRESS(AdditionalInfo) FROM
    People.People
    

    Now we can forward the compressed data directly to client who can decompress it, or we can decompress the same data in query:

    - SELECT name, surname, DECOMPRESS(info) AS original
      FROM Person
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: