Monday, August 26, 2013

What are Sparse Columns?

A SPARSE column is an ordinary type of column that has optimized storage for NULL values. It also reduces the space requirements for null values at the cost of more overhead to retrieve non-null values. In other words, a SPARSE column is better at managing NULL and ZERO values in SQL Server. It does not occupy any space in the database. Using a SPARSE column we may save up to 20 to 40 percent of space. We can define a column as a SPARSE column using the CREATE TABLE or ALTER TABLE statements.

Syntax

CREATE TABLE TableName(      .....      Col1 INT SPARSE,      Col2 VARCHAR(100) SPARSE,      Col3 DateTime SPARSE
      .....
)

No comments:

Post a Comment