Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL exception: Incorrect syntax near 'Index'

I have sql query:

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

I think it is about Index, because sql have command index. How can I say to sql, that it is my column?

like image 774
Andrey Avatar asked Dec 03 '25 17:12

Andrey


1 Answers

Index is a key word so you have to use [] for it as below

INSERT into ProjectFiles (Id,ProjectId,[Index]) VALUES (@Id,@ProjectId,@Index)
like image 166
Robert Avatar answered Dec 06 '25 05:12

Robert