• ashu.sajwan (2/17/2014)


    ...

    col1 varchar(Max) NULL,

    ...

    CREATE UNIQUE CLUSTERED INDEX cuq

    ON dbo.ExampleUnique (col1);

    It shows error: Column 'col1' in table 'dbo.ExampleUnique' is of a type that is invalid for use as a key column in an index.

    Any suggestions

    The reason for the failure is that columns of lob type (nvarchar(max), varchar(max), varbinary(max), ntext, text, image) can't be key columns in an index. So for example varchar(768) is OK, but varchar(MAX) isn't.

    Incidentally, I think this is a very good technique given that your version of SQL Server doesn't support filtered indexes.

    Tom