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)
 Copy data from one table to another

Author  Topic 

tkotey
Yak Posting Veteran

75 Posts

Posted - 2008-07-02 : 11:24:15
I would like to copy data from one table to another. What is the sql statement for it. This is NOT meant to be a backup. I would like to do this periodically.

Please help.

Thanks

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-07-02 : 11:45:18
Insert into target_table(column_list)
Select column_list from source_table

Madhivanan

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

tkotey
Yak Posting Veteran

75 Posts

Posted - 2008-07-03 : 03:14:10
quote:
Originally posted by madhivanan

Insert into target_table(column_list)
Select column_list from source_table

Madhivanan

Failing to plan is Planning to fail



Thanks Madhivanan. This is what I used and it worked
SET IDENTITY_INSERT target_table ON
Insert into target_table(column_list)
Select column_list from source_table
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-03 : 03:27:29
quote:
Originally posted by tkotey

quote:
Originally posted by madhivanan

Insert into target_table(column_list)
Select column_list from source_table

Madhivanan

Failing to plan is Planning to fail



Thanks Madhivanan. This is what I used and it worked
SET IDENTITY_INSERT target_table ON
Insert into target_table(column_list)
Select column_list from source_table



remember to set it back to off once you have copied data onto table.
Go to Top of Page
   

- Advertisement -