Insert statement

  • Hi!

    Lets say it I have 2 tables. First one has Name and eMail and second one has ID (Identity), Name and email. What is the corect syntax for inserting the name and email from the first table into the second one without using a cursor.

    Thank you,

    Radu

  • Something like this would work. I included the table DDL for clarity:

    CREATE TABLE TABLE1 (FULLNAME VARCHAR(20), EMAIL VARCHAR(30))

    CREATE TABLE TABLE2 (IDEN NUMERIC(12) IDENTITY(1,1), FULLNAME VARCHAR(20), EMAIL VARCHAR(30))

    INSERT INTO TABLE2 (FULLNAME, EMAIL)

    SELECT FULLNAME, EMAIL FROM TABLE1

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

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