Andrey
Andrey

Reputation: 311

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?

Upvotes: 3

Views: 3016

Answers (1)

Robert
Robert

Reputation: 25753

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

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

Upvotes: 11

Related Questions