alter table yourtable alter column colname int identity(1,1) not null
如果有空记录的话,首先应该干掉空记录,然后在可以使用修改语句 if exits( select count(column) from table where column_null is null) --看者办-- alter table table alter column column_null not null alter table table add constrant pk_table primary key ( column_null )
hjb111(唐老鸭) 的有语法错误,没有alter table TABLENAME alter column 这种语句。
alter table TABLENAME drop column a alter table TABLENAME add a int identity(1,1) not null alter table TABLENAME add constraint PK_game primary key(a)
对不起,hjb111(唐老鸭),我出现了失误,有alter table tablename alter column 语句。 please forgive me.
if exits( select count(column) from table where column_null is null)
--看者办--
alter table table alter column column_null not null
alter table table add constrant pk_table primary key ( column_null )
alter table TABLENAME add a int identity(1,1) not null
alter table TABLENAME add constraint PK_game primary key(a)
please forgive me.