SQL Exception: Incorrect Syntax Near "Index"

I have a sql query:

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

      

But when I try to insert an object, it throws an exception:

Incorrect syntax next to "Index". If intended as part of a table hint, the WITH WITH keyword and parenthesis are now required. See SQL Server Books Online for correct syntax

I think this is about Index

because sql has a command Index

. How can I tell sql this is my column?

+3


source to share


1 answer


Index

is a keyword, so you need to use []

it as shown below



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

      

+10


source







All Articles