There is already an object named 'tbltable1' in the database

南楼画角 提交于 2019-12-05 22:01:32

问题


I am trying to insert data from one table to another with same structure,

select * into tbltable1 from tbltable1_Link

I am getting the following error message:

There is already an object named 'tbltable1' in the database.

回答1:


The SELECT INTO statement creates a new table of the name you provide and populates it with the results of the SELECT statement.

I think you should be using INSERT INTO since the table already exists. If your purpose is in fact to populate a temporary table, then you should provide a table name that does not already exist in the database.

See MSDN for more information on this.




回答2:


If you are confident that tbltable1 is not required, you can drop the table first.

You may also want to consider using temporary tables...

Select * into ##MyTemporaryTable FROM tblTable1_Link 

You can then use the temporary table in this session. (Ending the session should drop the temporary table automatically, if I remember correctly. It's been a while since I've worked with SQL Server).



来源:https://stackoverflow.com/questions/1152811/there-is-already-an-object-named-tbltable1-in-the-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!