Can a sql server table have two identity columns?

前端 未结 9 1846
孤城傲影
孤城傲影 2020-11-27 06:23

I need to have one column as the primary key and another to auto increment an order number field. Is this possible?

EDIT: I think I\'ll just use a composite number a

9条回答
  •  -上瘾入骨i
    2020-11-27 06:54

    I've just created a code that will allow you inserting two identities on the same table. let me share it with you in case it helps:

    create trigger UpdateSecondTableIdentity
    On TableName For INSERT
    as
    update TableName
    set SecondIdentityColumn = 1000000+@@IDENTITY
    where ForstId = @@IDENTITY;
    

    Thanks,

提交回复
热议问题