ALTER A TABLE AND ADD IDENTITY COLUMN

  • I am having a table with 2 columns one is integer type and the other is varchar type.

    I want to add identity to my integer column. how can i do this using query analyser through alter table command?

    This can be done using enterprise manager.

  • Last time I checked, what enterprise manager does with fundamental modifications like this is rename the table create new table and copy the records back in then drop the old.  They just hide it all behind the magic curtain.

    So as far as I know you still would need to do this process in QA. 

    (That is, I don't think it's possible to add identity property to existing column with an alter.)

  • I agree with John but figured I'd point out that if you have Enterprise Manager to work with you can get a template (see what EM does) by performing the desired change and then (WITHOUT SAVING) click the "Save Change Script" toolbar button (3rd from left for me). You can then save the script to a file or copy and paste it out of the dialog window it creates. Note that this is just for saving the SQL script that EM would use to perform the change and does not actually perform the change. You can then just X out of designer and not save the changes.

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

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