database - SQL Alter Statement for Primary Key Column -


i having problem making column adding not null using sql alter statement. novice sql guidance great. using sql sever 2008 , receiving error stating column cannot added table because not allow nulls , not specify default definition. have data in table , looking add incremental primary key.

this sql using generate column

alter table epupdates.geninfo_optype3 add keyoptype integer not null 

this sql using make primary key/ identity column

alter table epupdates.geninfo_optype3 add primary key(keyoptype) 

try add default value column, if want make primary key, values must different each row, have update these value after creating new column , before create primary index.

alter table epupdates.geninfo_optype3 add keyoptype integer not null default 0 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -