i have a table with primary key column which is auto-increment id of numerals starting from 1000..
now i have been asked to make a unique key for each records which starts with C20161, C20162, C20163 and so on the series goes on.....
so it is actually an alphanumeric key that auto-increments....
i would like to know how to implement the same in sql and also can i update the same to existing records?
is 'sequence' what i am looking for or something else?
You need COMPUTED COLUMN for this purpose,
CREATE TABLE TableName( ID INT IDENTITY(1,1) NOT NULL, NewColumnName AS 'C' + CAST(ID AS VARCHAR(30)), .... Other columns list here )