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 1 table to another table

copy data from 1 table to another table

Scheduled Pinned Locked Moved Database
questiondatabasesaleshelp
4 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.
  • B Offline
    B Offline
    bapu2889
    wrote on last edited by
    #1

    Dear all, my question sounds very simple and yes it is very simple. what i am looking for just to copy data from one table to another table. i could write insert into table2 ( select * from table1) but in my case there is one database name MyDataBase.mdf and table name Customer so now when user performs year ending (31st march) option then system should create new folder for new year for ex. 2011 if user is working in 2010. so now in folder 2011 i have copy database which is MyDataBase.mdf now i want to copy all the customers from Customer table(in 2010 folder) to Customer table (in 2011 folder) so how can i copy data from same named database and same named table to same named database & table insert into Customer(select * from Customer) So can I differentiate insert Customer and select Customer table? I dont want to change table name in next year. waiting for your kind help.

    M P 2 Replies Last reply
    0
    • B bapu2889

      Dear all, my question sounds very simple and yes it is very simple. what i am looking for just to copy data from one table to another table. i could write insert into table2 ( select * from table1) but in my case there is one database name MyDataBase.mdf and table name Customer so now when user performs year ending (31st march) option then system should create new folder for new year for ex. 2011 if user is working in 2010. so now in folder 2011 i have copy database which is MyDataBase.mdf now i want to copy all the customers from Customer table(in 2010 folder) to Customer table (in 2011 folder) so how can i copy data from same named database and same named table to same named database & table insert into Customer(select * from Customer) So can I differentiate insert Customer and select Customer table? I dont want to change table name in next year. waiting for your kind help.

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      What can I say, your design sucks. Why not do it from the other end like every other organisation out there. Backup the database at the end of the year (2010) and remove the data for 2009 from the production database. This way you maintain continuity, you don't have to do any dancing around database names.

      Never underestimate the power of human stupidity RAH

      1 Reply Last reply
      0
      • B bapu2889

        Dear all, my question sounds very simple and yes it is very simple. what i am looking for just to copy data from one table to another table. i could write insert into table2 ( select * from table1) but in my case there is one database name MyDataBase.mdf and table name Customer so now when user performs year ending (31st march) option then system should create new folder for new year for ex. 2011 if user is working in 2010. so now in folder 2011 i have copy database which is MyDataBase.mdf now i want to copy all the customers from Customer table(in 2010 folder) to Customer table (in 2011 folder) so how can i copy data from same named database and same named table to same named database & table insert into Customer(select * from Customer) So can I differentiate insert Customer and select Customer table? I dont want to change table name in next year. waiting for your kind help.

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        What database? Sql Server? You can link the databases and then the INSERT/SELECT should work. But I prefer to use a connection to each one, use a DataReader to read from the source, and a parameterized INSERT for the destination. This allows me to report progress if the process is very long-running. In other situations, using the DataReader allows me to log duplicates and referential integrity issues without stopping the whole process.

        B 1 Reply Last reply
        0
        • P PIEBALDconsult

          What database? Sql Server? You can link the databases and then the INSERT/SELECT should work. But I prefer to use a connection to each one, use a DataReader to read from the source, and a parameterized INSERT for the destination. This allows me to report progress if the process is very long-running. In other situations, using the DataReader allows me to log duplicates and referential integrity issues without stopping the whole process.

          B Offline
          B Offline
          bapu2889
          wrote on last edited by
          #4

          hi thanks for your rep. so how can use datareder to get data from table any examples? waiting for your kind rep.

          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