Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
插入sql server错误:对象名称无效_Sql_Sql Server - Fatal编程技术网

插入sql server错误:对象名称无效

插入sql server错误:对象名称无效,sql,sql-server,Sql,Sql Server,我有以下声明: INSERT INTO TBL_VIDEOS ( TBL_VIDEOS.ID, TBL_VIDEOS.TITLE, TBL_VIDEOS.V_DESCRIPTION, TBL_VIDEOS.UPLOAD_DATE, TBL_VIDEOS.V_VIEWS, TBL_VIDEOS.USERNAME, TBL_VIDEOS.RATING, TBL_VIDEOS.V_SOURCE, TBL_VIDEOS.FLAG ) VALUES ('Z8MTRH

我有以下声明:

INSERT INTO TBL_VIDEOS (
  TBL_VIDEOS.ID,
  TBL_VIDEOS.TITLE,
  TBL_VIDEOS.V_DESCRIPTION,
  TBL_VIDEOS.UPLOAD_DATE,
  TBL_VIDEOS.V_VIEWS,
  TBL_VIDEOS.USERNAME,
  TBL_VIDEOS.RATING,
  TBL_VIDEOS.V_SOURCE,
  TBL_VIDEOS.FLAG
) 
VALUES 
('Z8MTRH3LmTVm',
'Why Creativity is the New Economy',
'Dr Richard Florida, one of the world's leading ...
    this stuff does not matter, it is just wasted space',
CURRENT_TIMESTAMP,
0,
1,
0,
'http://www.youtube.com/watch?v=VPX7gowr2vE&feature=g-all-u'
,0)
但我得到了这个错误信息:

无效的对象名称“TBL\U视频”


从该部分删除
TBL_视频

INSERT INTO TBL_VIDEOS (
  TBL_VIDEOS.ID,
  TBL_VIDEOS.TITLE,
  TBL_VIDEOS.V_DESCRIPTION,
  TBL_VIDEOS.UPLOAD_DATE,
  TBL_VIDEOS.V_VIEWS,
  TBL_VIDEOS.USERNAME,
  TBL_VIDEOS.RATING,
  TBL_VIDEOS.V_SOURCE,
  TBL_VIDEOS.FLAG
) 
应该是

INSERT INTO TBL_VIDEOS (
  ID,
  TITLE,
  V_DESCRIPTION,
  UPLOAD_DATE,
  V_VIEWS,
  USERNAME,
  RATING,
  V_SOURCE,
  FLAG
  )

您可以查看这一点,任何有
世界顶尖专家
等内容的地方都应该改为
世界顶尖专家
。通过执行两次单引号,您将从该部分中转义单引号

删除
TBL_视频

INSERT INTO TBL_VIDEOS (
  TBL_VIDEOS.ID,
  TBL_VIDEOS.TITLE,
  TBL_VIDEOS.V_DESCRIPTION,
  TBL_VIDEOS.UPLOAD_DATE,
  TBL_VIDEOS.V_VIEWS,
  TBL_VIDEOS.USERNAME,
  TBL_VIDEOS.RATING,
  TBL_VIDEOS.V_SOURCE,
  TBL_VIDEOS.FLAG
) 
应该是

INSERT INTO TBL_VIDEOS (
  ID,
  TITLE,
  V_DESCRIPTION,
  UPLOAD_DATE,
  V_VIEWS,
  USERNAME,
  RATING,
  V_SOURCE,
  FLAG
  )

您可以查看这一点,任何有
世界顶尖专家
等内容的地方都应该改为
世界顶尖专家
。通过两次单引号操作,您将跳过单引号

您需要跳过描述中的单引号:“世界领先的专家之一”

我不认为表名在本例中是一个问题,但它们是多余的

以下各项将起作用:

create table TBL_VIDEOS (
ID nvarchar(100), TITLE nvarchar(100), V_DESCRIPTION nvarchar(2000), UPLOAD_DATE nvarchar(100), V_VIEWS nvarchar(100), USERNAME nvarchar(100), RATING nvarchar(100), V_SOURCE nvarchar(100), FLAG nvarchar(100)
)

INSERT INTO TBL_VIDEOS ( 

 TBL_VIDEOS.ID, TBL_VIDEOS.TITLE, TBL_VIDEOS.V_DESCRIPTION, TBL_VIDEOS.UPLOAD_DATE, TBL_VIDEOS.V_VIEWS, TBL_VIDEOS.USERNAME, TBL_VIDEOS.RATING, TBL_VIDEOS.V_SOURCE, TBL_VIDEOS.FLAG) 

VALUES 

('Z8MTRH3LmTVm', 'Why Creativity is the New Economy', 'Dr Richard Florida, one of the world' + CHAR(39) + 's leading experts on economic competitiveness, demographic trends and cultural and technological innovation shows how developing the full human and creative capabilities of each individual, combined with institutional supports such as commercial innovation and new industry, will put us back on the path to economic and social prosperity.

Listen to the podcast of the full event including audience Q&A: http://www.thersa.org/events/audio-and-past-events/2012/why-creativity-is-the-new-economy

Our events are made possible with the support of our Fellowship. Support us by donating or applying to become a Fellow.

Donate: http://www.thersa.org/support-the-rsa Become a Fellow: http://www.thersa.org/fellowship/apply', CURRENT_TIMESTAMP, 0, 1, 0, 'http://www.youtube.com/watch?v=VPX7gowr2vE&feature=g-all-u' ,0)

你需要避开描述中的一句话:“世界顶尖专家之一”

我不认为表名在本例中是一个问题,但它们是多余的

以下各项将起作用:

create table TBL_VIDEOS (
ID nvarchar(100), TITLE nvarchar(100), V_DESCRIPTION nvarchar(2000), UPLOAD_DATE nvarchar(100), V_VIEWS nvarchar(100), USERNAME nvarchar(100), RATING nvarchar(100), V_SOURCE nvarchar(100), FLAG nvarchar(100)
)

INSERT INTO TBL_VIDEOS ( 

 TBL_VIDEOS.ID, TBL_VIDEOS.TITLE, TBL_VIDEOS.V_DESCRIPTION, TBL_VIDEOS.UPLOAD_DATE, TBL_VIDEOS.V_VIEWS, TBL_VIDEOS.USERNAME, TBL_VIDEOS.RATING, TBL_VIDEOS.V_SOURCE, TBL_VIDEOS.FLAG) 

VALUES 

('Z8MTRH3LmTVm', 'Why Creativity is the New Economy', 'Dr Richard Florida, one of the world' + CHAR(39) + 's leading experts on economic competitiveness, demographic trends and cultural and technological innovation shows how developing the full human and creative capabilities of each individual, combined with institutional supports such as commercial innovation and new industry, will put us back on the path to economic and social prosperity.

Listen to the podcast of the full event including audience Q&A: http://www.thersa.org/events/audio-and-past-events/2012/why-creativity-is-the-new-economy

Our events are made possible with the support of our Fellowship. Support us by donating or applying to become a Fellow.

Donate: http://www.thersa.org/support-the-rsa Become a Fellow: http://www.thersa.org/fellowship/apply', CURRENT_TIMESTAMP, 0, 1, 0, 'http://www.youtube.com/watch?v=VPX7gowr2vE&feature=g-all-u' ,0)
确保您添加了: 使用您的数据库的名称确保您添加了:
在我的例子中,SQL Server不喜欢对列部分使用单引号,也不喜欢对值部分使用双引号

错误

INSERT INTO [sample].[dbo].[users]
('username', 'password')
VALUES('hello', 'hello')

INSERT INTO [sample].[dbo].[users]
("username", "password")
VALUES("hello", "world")
正确

INSERT INTO [sample].[dbo].[users]
("username", "password")
VALUES('hello', 'world')

在我的例子中,SQL Server不喜欢对列部分使用单引号,也不喜欢对值部分使用双引号

错误

INSERT INTO [sample].[dbo].[users]
('username', 'password')
VALUES('hello', 'hello')

INSERT INTO [sample].[dbo].[users]
("username", "password")
VALUES("hello", "world")
正确

INSERT INTO [sample].[dbo].[users]
("username", "password")
VALUES('hello', 'world')

您需要转义特殊字符或保留字符。除了修复列列表中的表前缀和单引号外,您是否尝试过
dbo.TBL_VIDEOS
?是否确定您在正确的数据库中?
SELECT ID FROM TBL_VIDEOS
是否也会出现同样的错误?您需要转义特殊字符或保留字符。除了修复列列表中的表前缀和单引号外,您是否尝试过
dbo.TBL_VIDEOS
?是否确定您在正确的数据库中?您是否在TBL_视频的
SELECT ID
?@CodingBiz中遇到同样的错误(我无法评论您的答案,我太新了):删除列的名称将是更好的做法,但这不是问题所在。我相信这是因为他没有转义,或者说用ASCII等价物替换单引号。我不能在这里更改它,但我确实用HTML编码转义了。。qoute在我的数据库数据表中表示为';尝试通过从列列表中删除表名(无需架构签名)来重新编码,将每一行对齐(这允许您计数)。插入的另一种方法是使用select语句。突出显示select语句只允许您执行它,并确保返回正确的结果集和正确的列数。您可能还需要对表名进行架构签名。我见过有人在他们自己的用户名模式下创建一个表,引擎会首先尝试插入这个表,而不是正确的表。我猜dbo.TBL_VIDEOS将是您的模式签名表名。您确实需要始终包含模式。这对IntelliSense也有很大帮助。@CodingBiz(我不能评论你的答案,我太新了):删除列的名称会是更好的做法,但这不是问题所在。我相信这是因为他没有转义,或者说用ASCII等价物替换单引号。我不能在这里更改它,但我确实用HTML编码转义了。。qoute在我的数据库数据表中表示为';尝试通过从列列表中删除表名(无需架构签名)来重新编码,将每一行对齐(这允许您计数)。插入的另一种方法是使用select语句。突出显示select语句只允许您执行它,并确保返回正确的结果集和正确的列数。您可能还需要对表名进行架构签名。我见过有人在他们自己的用户名模式下创建一个表,引擎会首先尝试插入这个表,而不是正确的表。我猜dbo.TBL_VIDEOS将是您的模式签名表名。您确实需要始终包含模式。这对IntelliSense也有很大帮助。。顺便说一句,我的文字“世界领先的出口”中没有qoute,你试过@AaronBertrand在评论中说的话吗?还要验证表名的拼写。有时我们认为我们有
视频
,但它仍然是
视频
错误。。顺便说一句,我的文字“世界领先的出口”中没有qoute,你试过@AaronBertrand在评论中说的话吗?还要验证表名的拼写。有时我们认为我们有
视频
,但那是
视频