I have sql query:
我有SQL查询:
INSERT into ProjectFiles (Id,ProjectId,Index) VALUES (@Id,@ProjectId,@Index)
But when I try to insert object, it throws exception:
但是当我尝试插入对象时,它会抛出异常:
Incorrect syntax near 'Index'. If this is intended as a part of a table hint, A WITH keyword and parenthesis are now required. See SQL Server Books Online for proper syntax
“索引”附近的语法不正确。如果这是作为表提示的一部分,则现在需要A WITH关键字和括号。有关正确的语法,请参阅SQL Server联机丛书
I think it is about Index
, because sql have command index
. How can I say to sql, that it is my column?
我认为这是关于Index的,因为sql有命令索引。我怎么能对sql说,这是我的专栏?
1 个解决方案
#1
Index
is a key word so you have to use []
for it as below
索引是一个关键词,所以你必须使用[]如下所示
INSERT into ProjectFiles (Id,ProjectId,[Index]) VALUES (@Id,@ProjectId,@Index)
#1
Index
is a key word so you have to use []
for it as below
索引是一个关键词,所以你必须使用[]如下所示
INSERT into ProjectFiles (Id,ProjectId,[Index]) VALUES (@Id,@ProjectId,@Index)