SQL Server 2012
The documentation suggests space savings on sparse varchar columns if you have more than 60% nulls.
This seems inline with varchar docs "storage size is the actual length of the
data entered + 2 bytes"
However, when I run the following script, the results I see are that the tables are exactly the same size. Is my test erroneous or am I missing something else? Is there any benefit to having sparse varchar columns even when all rows are null?
Use Research CREATE TABLE UnSparsed( ID INT IDENTITY(1,1), FirstCol varchar(100), SecondCol varchar(100), ThirdCol varchar(100), primary key clustered (ID) with fillfactor = 100 ) GO CREATE TABLE Sparsed( ID INT IDENTITY(1,1), FirstCol varchar(100) SPARSE, SecondCol VARCHAR(100) SPARSE, ThirdCol varchar(100) SPARSE, primary key clustered (ID) with fillfactor = 100 ) GO set nocount on DECLARE @idx INT = 0 WHILE @idx < 50000 BEGIN INSERT INTO UnSparsed VALUES (NULL,NULL, null) INSERT INTO Sparsed VALUES (NULL, NULL, null) SET @idx+=1 END set nocount off GO sp_spaceused 'UnSparsed' GO sp_spaceused 'Sparsed' GO select * from sys.dm_db_index_physical_stats(db_id(), object_id('unsparsed'), null, null, 'detailed') select * from sys.dm_db_index_physical_stats(db_id(), object_id('sparsed'), null, null, 'detailed') DROP TABLE UnSparsed GO DROP TABLE Sparsed GO