SQL Server multiple schema object issues

我只是一个虾纸丫 提交于 2020-02-15 08:18:58

问题


I have database that has multiple schemas and objects under them. I want to consolidate the objects into one schema.

I tried

ALTER SCHEMA dbo TRANSFER <custom_schema>.<table_name>

I get an

object already exists message

However, I can't see it in the Management studio and

SELECT * from dbo.<table_name>

returns

object does not exist.

Looks like some system table entry is out of whack. I looked at sysobjects and it has only one entry for . Any suggestions on how to trouble shoot/ fix this issue is welcome.

Note: I can create a synonym

CREATE SYNONYM dbo.<table_name> FOR <custom_schema>.<table_name>

works fine


回答1:


According to this MSDN page your issue may be caused by a duplicate primary key name. i.e. your table_name's primary key name conflicts with a primary key name already defined within some other table in dbo.

To resolve this issue, rename the primary key for the table that you want to move. Use a name that does not appear as a primary key in the destination schema.



来源:https://stackoverflow.com/questions/4227173/sql-server-multiple-schema-object-issues

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