0

I have created this wide table with sparse column set which has more than 1024 columns:

CREATE Table [ExcelTestReport]
(
    [Id] [int] IDENTITY(1,1) PRIMARY KEY NOT NULL,
    [Product][varchar](50) SPARSE NULL,
    [Pdesc][varchar](50) SPARSE NULL,
    SpecialPurposeColumns XML COLUMN_SET FOR ALL_SPARSE_COLUMNS
)

But while executing the INSERT query I'm getting this error.

CREATE TABLE failed because column 'Pdesc' in table 'ExcelTestReport' exceeds the maximum of 1024 columns.

This is the INSERT query:

SET  @query ='Select
                     ,Pdesc
                     , value
                     , col
                    ,' + @cols + '
     Into [Repoting].[dbo].[ExcelTestReport]
     From
    (
            Select 
                     Product
                    ,Pdesc
                    , value
                    , col
            from #ResultDetailsPIVOT
            )x
        pivot 
        (
            max(value)
            for col in (' + @cols + ')
        ) p '
    Print(@query)
    EXECUTE(@query)

0 Answers0