gpt4 book ai didi

sql - 我刚创建的表上的MS SQL错误 "Invalid object name"

转载 作者:行者123 更新时间:2023-12-03 07:26:47 25 4
gpt4 key购买 nike

我得到一个

invalid object name



当我尝试将记录插入到刚创建的表中时发生错误。

我正在使用 Microsoft SQL 2000。我正在 super 用户帐户上测试所有这些,因此没有权限问题。

创建表:
CREATE TABLE [table_test2] (
[User 4] [varchar] (10) NULL ,
[User 3] [varchar] (10) NULL ,
[User 2] [varchar] (10) NULL ,
[User 1] [varchar] (10) NULL ,
[Spouse] [varchar] (10) NULL ,
[Sensitivity] [varchar] (10) NULL ,
[Referred By] [varchar] (10) NULL ,
[Profession] [varchar] (10) NULL ,
[Private] [varchar] (10) NULL ,
[Priority] [varchar] (10) NULL ,
[Other Address PO Box] [varchar] (10) NULL ,
[Organizational ID Number] [varchar] (10) NULL ,
[Office Location] [varchar] (10) NULL ,
[Notes] [varchar] (133) NULL ,
[Mileage] [varchar] (10) NULL ,
[Manager's Name] [varchar] (10) NULL ,
[Location] [varchar] (10) NULL ,
[Language] [varchar] (10) NULL ,
[Keywords] [varchar] (10) NULL ,
[Internet Free Busy] [varchar] (10) NULL ,
[Initials] [varchar] (10) NULL ,
[Home Address PO Box] [varchar] (10) NULL ,
[Hobby] [varchar] (10) NULL ,
[Government ID Number] [varchar] (10) NULL ,
[Gender] [varchar] (16) NULL ,
[E-mail 3 Display Name] [varchar] (10) NULL ,
[E-mail 3 Type] [varchar] (10) NULL ,
[E-mail 3 Address] [varchar] (10) NULL ,
[E-mail 2 Display Name] [varchar] (10) NULL ,
[E-mail 2 Type] [varchar] (10) NULL ,
[E-mail 2 Address] [varchar] (10) NULL ,
[E-mail Display Name] [varchar] (38) NULL ,
[E-mail Type] [varchar] (10) NULL ,
[E-mail Address] [varchar] (38) NULL ,
[Directory Server] [varchar] (10) NULL ,
[Children] [varchar] (10) NULL ,
[Categories] [varchar] (10) NULL ,
[Business Address PO Box] [varchar] (10) NULL ,
[Birthday] [varchar] (10) NULL ,
[Billing Information] [varchar] (10) NULL ,
[Assistant's Name] [varchar] (10) NULL ,
[Anniversary] [varchar] (10) NULL ,
[Account] [varchar] (10) NULL ,
[Telex] [varchar] (10) NULL ,
[TTY/TDD Phone] [varchar] (10) NULL ,
[Radio Phone] [varchar] (10) NULL ,
[Primary Phone] [varchar] (10) NULL ,
[Pager] [varchar] (10) NULL ,
[Other Phone] [varchar] (10) NULL ,
[Other Fax] [varchar] (10) NULL ,
[Mobile Phone] [varchar] (19) NULL ,
[ISDN] [varchar] (10) NULL ,
[Home Phone 2] [varchar] (10) NULL ,
[Home Phone] [varchar] (10) NULL ,
[Home Fax] [varchar] (10) NULL ,
[Company Main Phone] [varchar] (10) NULL ,
[Car Phone] [varchar] (10) NULL ,
[Callback] [varchar] (10) NULL ,
[Business Phone 2] [varchar] (10) NULL ,
[Business Phone] [varchar] (19) NULL ,
[Business Fax] [varchar] (19) NULL ,
[Assistant's Phone] [varchar] (10) NULL ,
[Other Country/Region] [varchar] (10) NULL ,
[Other Postal Code] [varchar] (10) NULL ,
[Other State] [varchar] (10) NULL ,
[Other City] [varchar] (10) NULL ,
[Other Street 3] [varchar] (10) NULL ,
[Other Street 2] [varchar] (10) NULL ,
[Other Street] [varchar] (10) NULL ,
[Home Country/Region] [varchar] (10) NULL ,
[Home Postal Code] [varchar] (10) NULL ,
[Home State] [varchar] (10) NULL ,
[Home City] [varchar] (10) NULL ,
[Home Street 3] [varchar] (10) NULL ,
[Home Street 2] [varchar] (10) NULL ,
[Home Street] [varchar] (10) NULL ,
[Business Country/Region] [varchar] (29) NULL ,
[Business Postal Code] [varchar] (10) NULL ,
[Business State] [varchar] (10) NULL ,
[Business City] [varchar] (17) NULL ,
[Business Street 3] [varchar] (10) NULL ,
[Business Street 2] [varchar] (10) NULL ,
[Business Street] [varchar] (30) NULL ,
[Job Title] [varchar] (10) NULL ,
[Department] [varchar] (10) NULL ,
[Company] [varchar] (34) NULL ,
[Suffix] [varchar] (10) NULL ,
[Last Name] [varchar] (16) NULL ,
[Middle Name] [varchar] (10) NULL ,
[First Name] [varchar] (10) NULL ,
[Title] [varchar] (10) NULL
)

创建表没有错误!!

我可以从表中选择:
select * from table_test2  

但是,当我尝试插入时,出现错误,表明该对象不适合:
insert into table_test2
('User 4', 'User 3', 'User 2')
values
('a','b','c')

返回错误:

Server: Msg 208, Level 16, State 3, Line 1 Invalid object name 'table_test'.

最佳答案

他们没有相同的名字。您创建的一个带有2后缀。

CREATE TABLE [table_test2]


select * from table_test 

如果确定您的select/insert语句没有发生类似的错误,我建议运行以下命令。
select * from 
sysobjects /*For SQL Server 2000*/
where name like 'table_test%'

另外,您的 insert语句看起来很狡猾。我认为您需要方括号或双引号而不是单引号。我不确定这是否会产生您所看到的错误。
insert into table_test
([User 4], [User 3], [User 2])
values
('a','b','c')

关于sql - 我刚创建的表上的MS SQL错误 "Invalid object name",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3309365/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com