Copy from "edit top N rows" with an auto increment field

  • I know how to copy and paste data from one table to another table with INSERT and SELECT query.

    I just want to know is it possible to do this from "edit top N rows" if you have an auto increment field in both tables?

    ___________________________________
    Computer Enterprise Masoud Keshavarz
    I don't care about hell.
    If I go there I've played enough Diablo to know how to fight my way out.

  • masoudk1990 (1/13/2015)


    I know how to copy and paste data from one table to another table with INSERT and SELECT query.

    I just want to know is it possible to do this from "edit top N rows" if you have an auto increment field in both tables?

    There is no edit command in SQL.

    You could do a SELECT TOP N with a ORDER BY on the Identity column. But if you're inserting one identity value into another table's identity column, you need to make sure you've used the SET IDENTITY_INSERT statement. And since this can only be on for one table at a time (or could the last time I checked), you need to ensure you turn it off after you're done.

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

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

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