Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 copying data from one table to other

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-02-01 : 07:43:14
ramana writes "I have data in one table. I want to insert the same data into the other table in the same database."

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-02-01 : 07:49:09
If the two tables have the exact same structure, then this will work:

INSERT INTO table2 SELECT * FROM table1

If the two tables have a different structure, you need to explicitly list the columns they each have in common:

INSERT INTO table2 (col1, col2, col3) SELECT col1, col2, col3 FROM table1

Books Online has all the details behind the INSERT command.

Go to Top of Page
   

- Advertisement -