Copy data from one table to another problem
-
Hi to all i want to copy entire data from one of my table to that of another table. source table is created and having 1000 of rows and destination table is not created this i want to do in a single statment. Thanks in advance.
soniasan wrote:
i want to copy entire data from one of my table to that of another table. source table is created and having 1000 of rows and destination table is not created this i want to do in a single statment.
You will need to look up the
SELECT INTO
SQL statement. -
soniasan wrote:
i want to copy entire data from one of my table to that of another table. source table is created and having 1000 of rows and destination table is not created this i want to do in a single statment.
You will need to look up the
SELECT INTO
SQL statement.Be warned, if there are large volumes of data using the
SELECT INTO
method could lock all other processes out as it locks the system tables (such as syscolumns, sysobjects etc) for the duration of the select. It is much better to do it in two steps:SELECT * INTO new_table FROM old_table WHERE 1 = 2 -- creates the new table
INSERT INTO new_table SELECT * FROM old_table -- populate itBob Ashfield Consultants Ltd