Question

I just tried this and got the helpful message that

Column 'Username' in table 'Users' is of a type that is invalid for use as a key column in an index.

Username is an nvarchar(max) column.

Was it helpful?

Solution

You can't add a index to a nvarchar(max) or varchar(max) column but it can be part of an index.

You can include it in an index but then that index needs to created/rebuilt offline.

Taking a guess from your column name 'Username' I would change the column type to something smaller like a nvarchar(50). The nvarchar(max) datatype can store up to 4Gb of text and is used for more full text storage (in that use you would setup full text searching).

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