将现有列转换为第二个自动递增列

Convert exiting column into 2nd auto increment column

在 Sql 服务器中我有一个 table StudentMaster,其中我有一个 ID(Primary) 列和其他 "StudentRollNo"(Not Primary) Column 。我需要将 StudentRollNo 转换为另一个标识列。我试过了:

ALTER TABLE studentMaster alter column StudentRollNo AS ID + 0

但这不起作用 'AS' 并且“+”在此查询中不被接受table。 Sql 服务器中还有其他选项吗??

CREATE SEQUENCE seq START WITH watever_number INCREMENT BY 1;

ALTER TABLE studentMaster ADD CONSTRAINT constraint_name 
      DEFAULT NEXT VALUE FOR seq FOR StudentRollNo 

将 watever_number 替换为您列中的最高值

您可以在您的数据库 table

上使用 SQL Computed column
alter table TableName add ComputedColumnName as Id -- Identity column name