SQL Server Create Table 给出了对象''已经存在但不存在的错误

SQL Server Create Table gives error that object '' already exists when it doesn't

抱歉,如果这看起来像是重复的,但我找不到适合我的情况的答案。我正在尝试在数据库 NBFP 中创建 table cardissuedates

这是我的创建语句:

USE NBFoodPantry

CREATE TABLE cardissuedates 
(
    clientid char(36) NOT NULL,
    issuedate date NOT NULL

    CONSTRAINT cardissuedates 
       PRIMARY KEY CLUSTERED (clientid ASC)
           WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, 
                 IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, 
                 ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
) ON [PRIMARY]

我收到这个错误:

Msg 2714, Level 16, State 5, Line 33
There is already an object named 'cardissuedates' in the database.

Msg 1750, Level 16, State 0, Line 33
Could not create constraint or index. See previous errors.

table 不存在于 NBFB 数据库中,我在检查 master 和 NBFB 时找不到它。

我试过了

select * 
from sys.all_objects
where name like '%ca%'
order by 1

select * 
from sys.tables
where name like 'c%'
order by 1

select * 
from sys.all_columns
where name like 'c%'
order by 1

我什至创建了一个新数据库并执行了这个创建语句,在 USE 语句中使用了新的数据库名称。同样的错误。

我已经停止了所有退出 SSMS 的服务。似乎没有任何效果。 又不知道去哪里找了。

任何帮助将不胜感激。

谢谢

您给主键的名称与 table 相同,这是不允许的,因为两者都是架构范围的对象,并且多个对象不能具有相同的 schema_name.object_name。您可以这样做:

CREATE TABLE cardissuedates ( 
    clientid char(36) NOT NULL, 
    issuedate date NOT NULL CONSTRAINT 
    pk_cardissuedates PRIMARY KEY CLUSTERED ( clientid ASC )
    WITH (
        PAD_INDEX = OFF, 
        STATISTICS_NORECOMPUTE = OFF, 
        IGNORE_DUP_KEY = OFF, 
        ALLOW_ROW_LOCKS = ON, 
        ALLOW_PAGE_LOCKS = ON, 
        FILLFACTOR = 90
    ) ON [PRIMARY] 
) ON [PRIMARY]

我刚刚在约束中添加了前缀 PK_