Identity column

  • If a table named TBL1 has a column COL1 which is numeric(p,s), primary key, clustered: How to alter COL1 to make it also IDENTITY(p,s) without affecting its other properties (primary key, clustered)

    (SQL BOL in ALTER TABLE states that you can't alter a column that is a primary key)

    Edited by - ezzatm on 08/06/2003 02:15:09 AM

    Edited by - ezzatm on 08/06/2003 02:16:48 AM

    EM

  • You'll need to 1) rename the table 2) recreate the table specifying IDENTITY for COL1 3) insert data from the original table.

    Note also that, to be an IDENTITY, the scale of COL1 must be zero. ie. NUMERIC(p,0)

    Cheers,

    - Mark


    Cheers,
    - Mark

  • Appreciate all help. Now; does it differ if COL1 was not primary key and not indexed (COL1 is numeric(p,0))

    Server is: SQL 2000, SP3

    EM

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply