copy data from 1 table to another table
-
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.
-
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.
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
-
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.
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.
-
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.