Home Forums SQL Server 2008 SQL Server Newbies IDENTITY_INSERT, and Using Alphanumeric Autoincrement Primary Key RE: IDENTITY_INSERT, and Using Alphanumeric Autoincrement Primary Key

  • Hi Folks,

    Thanks again to every1 looking into this for me.

    I was in need to generate Alphanumeric ID ( An Identity which is based on PRIMARY KEY [assigned to every row for an user information] AND User Status [Suppose Status can have values {A,B,C,D,E}]

    So the Alphanumeric ID for First user could be '1A', Similarly second user '2A', Third '3B', Fourth '4A'.. and some nth user has 'nE'.

    So now,

    I've found the logic to Derive this Alphanumeric ID.

    Of course, It cannot be a Primary KEY so my assumption about it was false tough it can be a UNIQUE KEY.

    The logic is as below,

    UPDATE EMP_DETAILS SET Use_ID = CAST((EMP_STATUS+''+CAST(ID as varchar)) as varchar)

    Where

    EMP_DETAILS: Table for User information.

    ID: Primary Key & EMP_STATUS[As the user chooses from Front end]

    But finally, what i got is I have to re-look to the written records and re-process for the USE_ID(the required Alpha numeric ID).

    So my question is, Is there any other way like to achieve this, alike the derived columns are(Value get calculated and store automatically)?