Vijay
asked on
copy data in SQL Server
While i try to copy data from one table to another table in sql server 2008 i am getting below error.
There is already an object named 'table123' in the database.
Just i am copying this table to another database.
i already created schema in another database with same table name.
There is already an object named 'table123' in the database.
Just i am copying this table to another database.
i already created schema in another database with same table name.
ASKER
I used select * into .
If i use select * into, it is creating table and copying data. But it not creating constraints.
If i use select * into, it is creating table and copying data. But it not creating constraints.
It will not. Furthermore, please be aware that the metadata tables, such as sys.tables, sys.columns are exclusively locked during the execution of such statement and as such this isn't quite a good practice in case of large table in production environment.
Better still, just create a script from original table (with constraint of, course), change table name in the script, execute the script and then import the data with the help of insert into...select from
Better still, just create a script from original table (with constraint of, course), change table name in the script, execute the script and then import the data with the help of insert into...select from
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you Vikas
try use a Insert into ... Select statement instead.
OR else you need to drop that table before running your existing statement.