Question: Creating **`non-clustered index`** on columns with `varchar(max)` is not allowed in `sql server` .

So, what is the maximum `varchar` length can `non-clustered index` be created on?

Answer: 
Key column length should not exceed 900 bytes,but with sqlserver 2016 cu2,this is 1700 bytes..

You can include max columns as included,though they should be not part of key columns..

```
create table t1
(
col1 varchar(1700),
id varchar(max)
)

create index nc on t1(col1) 
include (id)

```

Just to add, from SQLServer 2012, you can also rebuild index columns which are of LOB type, though text, ntext and image are not supported..

Remus Rusanu has good blog on why online index rebuild operations were not supported in earlier versions of 2012..

**Further reading :**  

[varchar(max) everywhere?](https://stackoverflow.com/questions/2091284/varcharmax-everywhere)  

[Online Index Operations for indexes containing LOB columns](http://rusanu.com/2011/08/05/online-index-operations-for-indexes-containing-lob-columns/)
The maximum number of bytes for a non-clustered Index (pre 2016) is 900:

<https://learn.microsoft.com/en-us/sql/sql-server/maximum-capacity-specifications-for-sql-server>

So, give VARCHAR(900) a go and let us know how you get on.