MikeJ
MikeJ

Reputation: 14565

How do you create a wide table in SQL Server 2008? and what are its limitations on use?

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 ?

Upvotes: 12

Views: 23577

Answers (5)

fifamaniac04
fifamaniac04

Reputation: 2383

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

Upvotes: 2

Josh Yeager
Josh Yeager

Reputation: 3793

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

Upvotes: 2

HLGEM
HLGEM

Reputation: 96580

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.

Upvotes: 3

Scott Ivey
Scott Ivey

Reputation: 41568

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...

Upvotes: 10

Tom H
Tom H

Reputation: 47464

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

From here

Upvotes: 4

Related Questions