Table hiding in SQL Server database?

时光毁灭记忆、已成空白 提交于 2019-12-06 07:40:46

问题


I am transferring data into a table all of sudden I went throgh a crazy problem I have never seen in my career.

Msg 208, Level 16, State 1, Line 1
Invalid object name 'dbo.Table_Report'.

Then I tried to create a table with same name and again I got fallowing error

Msg 2714, Level 16, State 6, Line 2
There is already an object named 'Table_Report' in the database.

What went wrong I need to send data in to table asap but I am unable to do that at least I can't delete the table

Cannot drop the table 'Table_Report', because it does not exist or you do not have permission.

Note: I have admin rights on the database.

Can you guys look what went wrong??


回答1:


select Schema_name(schema_id) from sys.tables where name ='Table_report';

which schema is the result? If you want to move it do that:

ALTER SCHEMA dbo
TRANSFER SchemaSource.Table_report;

http://msdn.microsoft.com/en-us/library/ms173423%28v=sql.105%29.aspx




回答2:


We recently had this issue at work, what has probably happened is that someone created a table called Table_report under their username (instead of as the DBO - Database Owner). You should try:

Drop Table Table_report

Then rerun your query.

EDIT: You should be able to run the following query to find all the existing tables in the database and find out which username is attached to the table

select ss.name ,st.* from sys.tables st
inner join sys.schemas ss
 on ss.schema_id = st.schema_id


来源:https://stackoverflow.com/questions/18659426/table-hiding-in-sql-server-database

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