问题
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