I would like to modify my table and add the SPARSE parameter to all fields that contain many NULL values. What is the correct syntax for this ALTER TABLE command?
SPARSE
ALTER TABLE
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
Other answers work, but you can also get away with:
ALTER TABLE #foo ALTER COLUMN bar ADD SPARSE;
This way you do not need to look for the column type or nullability value.
ALTER TABLE Xtable ADD myCol int sparse null