Sql-server – SQL – double column used from primary key with autoincrement

auto-incrementprimary-keysql server

I am user the following as primary key in the SqlDB:

I am doing the Index as Autoincrement, but it is autoincremented in general not per user.
Example userid=1,index=1, then insert another for userid=2 then inserted userid=2index=2
Then we insert a new entry for userid=2 theninserted userid=2 index=3 and not 1.

Is it possible to do what I want?

Best Answer

You can't have more than one IDENTITY column per a table. Use MAX(index)+1 where userid=X, when inserting a new row without auto-increment.