Microsoft SQL Server

How to insert data from one table to another

This topic contains 0 replies, has 1 voice, and was last updated by Profile photo of Jitto P.Jose Jitto P.Jose 3 years, 1 month ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #16052
    Profile photo of Jitto P.Jose
    Jitto P.Jose
    Moderator

    Hi All,
    Following is an example for inserting data from one table to another.

    INSERT INTO NewTable(FirstName, LastName)
    SELECT FirstName, LastName
    FROM OldTable

    For the above code, the table NewTable should be created before copying data.

    Following example will create the NewTable at the time of inserting data from OldTable

    SELECT FirstName, LastName
    INTO NewTable
    FROM OldTable

    Thanks,
    Jitto P.Jose

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.