开发者

Creating Index on Table in a schema

I am logged in as 'sa', with full admin rights, and I am running the following command:

CREATE NONCLUSTERED INDEX [IDX_EntityAuditId] ON [Maintenance.EntityAuditMessagesArchive] 
([EntityAuditId] ASC) ON [PRIMARY]

and getting the error:

Cannot find the object "Maintenance.EntityAuditMessagesArchive" because it does not exist or you do not have permissions.

The object does exist, because 开发者_开发技巧I can select from it. Furthermore, the command works if the table is not in a schema. i.e.

CREATE NONCLUSTERED INDEX [IDX_EntityAuditId] ON [EntityAuditMessagesArchive] 
    ([EntityAuditId] ASC) ON [PRIMARY]

works (when I create the table without a schema, of course).

So, I can't create the index when the table is in the Maintenance schema. Why is this?


You have a . in your name. I'm guessing you need to change it to:

[Maintenance].[EntityAuditMessagesArchive]

A period inside the brackets indicates it is a part of the name, not a separator.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜