sql server - Adding a new primary key to existing table -


i have table following details

table name employee , columns

empid (pk smallint not null) empname (varchar 256 not null) org (fk smallint not null) function (fk smallint not null) eff_date (datetime null) audit_id (varchar null) 

now have add coulmn table add_uid , make primary key

i using query failing.

alter table cvadmin.employee  add add_uid  varchar(32) null,  constraint pk_employee primary key [non]clustered (add_uid) go 

table 'employee' has primary key defined on it.

edit

the idea here new column should unique if fails can throw _key_violation code manipulation done

to add unique constraint (which additional primary key) this:

alter table employee add constraint uc_uid unique (add_uid) 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -