|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Yesterday @ 9:30 AM
Points: 830,
Visits: 1,197
|
|
|
|
|
|
SSCrazy Eights
        
Group: General Forum Members
Last Login: Yesterday @ 8:46 AM
Points: 8,547,
Visits: 8,204
|
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Tuesday, April 30, 2013 6:32 AM
Points: 1,592,
Visits: 352
|
|
From http://msdn.microsoft.com/en-us/library/ms174979.aspx:
SPARSE Indicates that the column is a sparse column. The storage of sparse columns is optimized for null values. Sparse columns cannot be designated as NOT NULL. For additional restrictions and more information about sparse columns, see Use Sparse Columns.
If a sparse column cannot be designated as NOT NULL, is there a NULL/NOT NULL property to be transferred or does making the column SPARSE automatically make the column NULLable? Or does a SPARSE column have a NULL property that just cannot be changed to NOT NULL? Just wondering...
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Today @ 4:55 PM
Points: 3,226,
Visits: 64,039
|
|
Ernie Schlangen (8/29/2012)
From http://msdn.microsoft.com/en-us/library/ms174979.aspx: SPARSE Indicates that the column is a sparse column. The storage of sparse columns is optimized for null values. Sparse columns cannot be designated as NOT NULL. For additional restrictions and more information about sparse columns, see Use Sparse Columns.
If a sparse column cannot be designated as NOT NULL, is there a NULL/NOT NULL property to be transferred or does making the column SPARSE automatically make the column NULLable? Or does a SPARSE column have a NULL property that just cannot be changed to NOT NULL? Just wondering... 
Run Wayne's code... aftewards do sp_help Table1 to get the structure of the table back. There's still a Nullable property.
I just never realized the Nullability of a column transferred with INTO. That's neat, just not something I ever worried about because I generally use INTO #temptables, not to make new ones, and as I"m normally dumping partial contents of tables into the #temp, the values are what I'm normally more interested in.
--Mark Tassin MCITP - SQL Server DBA Proud member of the Anti-RBAR alliance. For help with Performance click this link For tips on how to post your problems
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Tuesday, April 30, 2013 6:32 AM
Points: 1,592,
Visits: 352
|
|
Thanks for the quick answer! I suspected that I would get an answer here before I had time to try to find it myself!
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Saturday, February 02, 2013 5:42 AM
Points: 190,
Visits: 74
|
|
| Good question but tough......
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 4:11 PM
Points: 3,390,
Visits: 3,403
|
|
| Great topic and question. Thanks!
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Saturday, February 02, 2013 5:42 AM
Points: 190,
Visits: 74
|
|
| Sparse columns are a property of the storage layer, rather than the logical table. Therefore a SELECT…INTO statement does not copy over the sparse column property into a new table.
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Yesterday @ 10:38 AM
Points: 151,
Visits: 269
|
|
udayroy15 (8/29/2012) Sparse columns are a property of the storage layer, rather than the logical table. Therefore a SELECT…INTO statement does not copy over the sparse column property into a new table.
I was just looking into this. http://msdn.microsoft.com/en-us/library/cc280604.aspx
"Catalog views for a table that has sparse columns are the same as for a typical table. The sys.columns catalog view contains a row for each column in the table and includes a column set if one is defined."
"Sparse columns are a property of the storage layer, rather than the logical table. Therefore a SELECT…INTO statement does not copy over the sparse column property into a new table."
SELECT OBJECT_NAME(object_id) AS TableName, name AS ColumnName, is_sparse FROM SYS.COLUMNS WHERE object_id IN (object_id('Table1'), object_id('Table2'))
TableName ColumnName is_sparse Table1 RowID 0 Table1 DateTimeStamp 0 Table1 Col1 1 Table1 Col2 1 Table1 Col3 1 Table1 TblColumnSet 0
Table2 RowID 0 Table2 DateTimeStamp 0 Table2 Col1 0 Table2 Col2 0 Table2 Col3 0 Table2 TblColumnSet 0
|
|
|
|
|
SSCoach
         
Group: General Forum Members
Last Login: 2 days ago @ 1:46 PM
Points: 18,732,
Visits: 12,329
|
|
|
|
|