简体   繁体   English

SQL异常:'Index'附近的语法不正确

[英]SQL exception: Incorrect syntax near 'Index'

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. 如果这是作为表提示的一部分,则现在需要A WITH关键字和括号。 See SQL Server Books Online for proper syntax 有关正确的语法,请参阅SQL Server联机丛书

I think it is about Index , because sql have command index . 我认为这是关于Index ,因为sql有命令index How can I say to sql, that it is my column? 我怎么能对sql说,这是我的专栏?

Index是一个关键词,所以你必须使用[]如下所示

INSERT into ProjectFiles (Id,ProjectId,[Index]) VALUES (@Id,@ProjectId,@Index)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM