Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Copy data from one table to another problem

Copy data from one table to another problem

Scheduled Pinned Locked Moved Database
help
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    soniasan
    wrote on last edited by
    #1

    Hi to all i want to copy entire data from one of my table to that of another table. source table is created and having 1000 of rows and destination table is not created this i want to do in a single statment. Thanks in advance.

    C 1 Reply Last reply
    0
    • S soniasan

      Hi to all i want to copy entire data from one of my table to that of another table. source table is created and having 1000 of rows and destination table is not created this i want to do in a single statment. Thanks in advance.

      C Offline
      C Offline
      ChandraRam
      wrote on last edited by
      #2

      soniasan wrote:

      i want to copy entire data from one of my table to that of another table. source table is created and having 1000 of rows and destination table is not created this i want to do in a single statment.

      You will need to look up the SELECT INTO SQL statement.

      A 1 Reply Last reply
      0
      • C ChandraRam

        soniasan wrote:

        i want to copy entire data from one of my table to that of another table. source table is created and having 1000 of rows and destination table is not created this i want to do in a single statment.

        You will need to look up the SELECT INTO SQL statement.

        A Offline
        A Offline
        Ashfield
        wrote on last edited by
        #3

        Be warned, if there are large volumes of data using the SELECT INTO method could lock all other processes out as it locks the system tables (such as syscolumns, sysobjects etc) for the duration of the select. It is much better to do it in two steps:

        SELECT * INTO new_table FROM old_table WHERE 1 = 2 -- creates the new table
        INSERT INTO new_table SELECT * FROM old_table -- populate it

        Bob Ashfield Consultants Ltd

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups