# How to Fix SQL/SQL Server the 1024 Column Limit

For normal tables, SQL/Server has a hard limit of 1024 columns. This article explains what to do if your Salesforce table has more than 1024 columns.

## Overall Solution

SQL/Server will support up to 30,000 columns per table but to achieve this columns above the 1024 limit must be created as SPARSE columns. A sparse column is a column whose value is stored in a special column that contains an XML document. Naturally, sparse columns are more expensive to search and update than regular columns but they do provide a way to get past the 1024 limit.

The produced to fix a problem table is:

1. Turn a table into a wide table by adding a new column to hold sparse column values.
2. Identify which columns to change to sparse columns.
3. ALTER the definition of the identified columns to be sparse.

## Example

The following example code creates a regular table and then turns it into a wide table and changes most of its columns to be sparse.

CREATE TABLE SparseExample (

id BIGINT IDENTITY

,name VARCHAR(50)

,address VARCHAR(255)

,other VARCHAR(MAX)

);

ALTER TABLE SparseExample ADD sparseColumns XML COLUMN\_SET FOR ALL\_SPARSE\_COLUMNS;

ALTER TABLE SparseExample ALTER COLUMN name VARCHAR(50) SPARSE;

ALTER TABLE SparseExample ALTER COLUMN address VARCHAR(255) SPARSE;

ALTER TABLE SparseExample ALTER COLUMN other VARCHAR(MAX) SPARSE;

INSERT INTO SparseExample(name,address,other) VALUES(‘Capstorm’, ‘Florida’, ‘Now is the time for all good men…’);

SELECT name, address,other, sparseColumns FROM SparseExample

## For Additional Help

Google *SQL Server Wide Table* and you will find many helpful articles.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.capstorm.com/frequently-asked-questions/problems-solutions/how-to-fix-sql-server-the-1024-column-limit.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
