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 2005 Forums
 Transact-SQL (2005)
 copying data

Author  Topic 

mshsilver
Posting Yak Master

112 Posts

Posted - 2011-08-09 : 10:56:16
Hi,

I am trying to copy all the data from one table (table a) to another table (table b) both tables have exactly the same table structure and are located in the same database on the same server.

I can only find scripts that create the destination table and I just want to copy the data as the table is already there. If anyone can tell me the type of query I want to search for or point me in the right direction that would be great.

Thanks in advance.


russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-08-09 : 11:01:30
INSERT INTO DestinationTable (column1, column2, column3...)
SELECT column1, column2, column3...
FROM SourceTable;
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-08-09 : 11:01:56
Insert into target_table(col_list)
select col_list from source_table

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-08-09 : 11:06:44


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

mshsilver
Posting Yak Master

112 Posts

Posted - 2011-08-09 : 11:07:18
Thank you both for the help.
Go to Top of Page
   

- Advertisement -