Question

I was reading the Maximum Capacity Specifications for SQL Server and I came across the designation of a wide table. It's different from a standard table in that is can have as many as 30,000 columns as opposed to a normal (narrow) table that is limited to the more familiar 1024 columns. I googled for wide table, but nothing seem to come up relevant. Does this new table type have a more formal name???

So why do we have two different types of tables, how do you create this special table and what are the limitations of using this table that can seemingly hold more data ? anhyone know ?

Was it helpful?

Solution

A wide table is a table that uses column sets and sparse columns. It still follows the same width restrictions per row (8019 bytes) - so you'd typically only use it when your columns are mostly all nulls.

See here for more info on...

OTHER TIPS

"To create or change a table into a wide table, you add a column set to the table definition."

From here

You usually do not want to do this however! There are size restrictions on the rows and it can be slower to retrieve data than if you use related tables (even those with one-to-one relationships). I've never yet seen an instance where this was a better idea than related tables.

Another limitation is that wide tables don't work with transactional or merge replication. See the "SQL Server Technologies That Support Sparse Columns" section here: http://msdn.microsoft.com/en-us/library/cc280604(v=sql.105).aspx

CREATE TABLE [UR_DB].[dbo].[DesiredTableName]
(DocID int PRIMARY KEY,
Title varchar(200) NOT NULL,
ProductionSpecification varchar(20) SPARSE NULL,
ProductionLocation smallint SPARSE NULL,
MarketingSurveyGroup varchar(20) SPARSE NULL,
MarketingProgramID int SPARSE NULL,
SpecialPurposeColumns XML COLUMN_SET FOR ALL_SPARSE_COLUMNS);

Creating Complex Test Databases - Creating a Table with more than 1,024 Columns

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top