Need to Duplicate Data

  • Hi all

    i have a strange requirement of duplicating data in a table. I have 26 rows to be copied from the same table to the same table. The table has a primary key and identity column.

    I set the Identity insert on and copied the data over but the primary key is a char datatype and is not coming up correctly and am unable to update it either.

    I used the the following syntax

    Insert into table (col names incl primary key col)

    select max(primarykey) + 1 and rest of the cols

    Can some one please advise

    Thanks in advance

    Vani

  • Providing the DDL of the table involved, some sample data and the expected result would help a lot in solving your problem

    Also if you tried something yourself provide the proper code and the error/issues you get when you tried that code.


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • Note that you're inserting in a batch here, so MAX(PK) will be the same for all rows you are inserting.

    Do you want duplicate identities? Why not just let the identity fill with new values?

  • Hi all

    Thanks for your help... I have figured it out...

    Cheers

    Vani

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

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