Search code examples
sqlsql-serversql-server-2008alter

SQL Server: alter table, how to add SPARSE definition


I would like alter my table and add SPARSE option to all fields that contain a lot of NULL values. What is the right syntax for this ALTER TABLE command?


Solution

  • CREATE TABLE #Foo
    (
    X INT NULL,
    Y INT NULL
    )
    
    
    ALTER TABLE #Foo ALTER COLUMN Y INT  SPARSE NULL 
    
    ALTER TABLE #Foo ALTER COLUMN X INT SPARSE NULL