question

cstephen avatar image
cstephen asked

How to copy of table with datas into another table

i want to copy of one table which is already in records to move another table.
sql-server-2005
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

do you want to move the data from one table to another??
0 Likes 0 ·
Kev Riley avatar image
Kev Riley answered
There are lots of ways to achieve this : select col1, col2, col3, ..... into YourTable_COPY from YourTable Or you could create the table first with a `CREATE TABLE YourTable_COPY ....` and then insert into YourTable_COPY select col1, col2, col3, ..... from YourTable Or you could use SSIS Or your could [BCP][1] out the data and then BCP in into a new table Or....lots more [1]: http://msdn.microsoft.com/en-us/library/ms162802.aspx
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Which method is best depends on the details. As a very broad over simplification, I generally prefer using "insert into..." when the two tables are on the server and generally reach for SSIS or occassionally a tool like SQL Data Compare when going across servers.
0 Likes 0 ·
ThomasRushton avatar image
ThomasRushton answered
Hang on - you're asking about *moving* data rather than *copying*? And yet your question title is copying... If you're just interested in moving it, then you could always do `sp_rename` on the old table and then recreate the new table with the same schema... See for more on `sp_rename`. (Note that this is not particularly safe...)
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

+1 : nice spot!
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.