Here is what I am trying to do:
SELECT * INTO new_table FROM old_table WHERE 1=2; ALTER TABLE new_table ADD CONSTRAINT pk_new_table_id PRIMARY KEY(id); SET IDENTITY_INSERT new_table ON
Basically, I want to create a new table based on the structure of the existing one, and then enable auto-increment for the ID field. However, when I try to insert rows, I get the following:
Table 'new_table ' does not have the identity property. Cannot perform SET operation.
Can someone enlighten me about what I am doing wrong or how should I actually do this?
source share