Sachin Yadav
Sachin Yadav

Reputation: 187

Sql server 2012:error Invalid Column Name while the table having these column

I create a table employee having 4 columns (eid, ename, ejob, esalary) after this when i m inserting values into this table i m getting error that

 invalid column name 
insert into employee values(1001,"Sachin","Army",50000) at column ename and ejob

can any one tell me what does it mean Invalid column name and how can i remove this error.

Upvotes: 0

Views: 691

Answers (1)

Vladimir Baranov
Vladimir Baranov

Reputation: 32695

You are using double quote (") instead of single quote (').

Your query should be something like this:

insert into employee values(1001,'Sachin','Army',50000)

It would be even better if you explicitly listed the columns of the table. The structure and order of the columns in the table can change, so if you don't list columns explicitly you can easily introduce hard to find bugs. Actually, even better would be if you explicitly included the table schema (usually dbo).

insert into dbo.employee(eid, ename, ejob, esalary) 
values(1001,'Sachin','Army',50000);

Upvotes: 1

Related Questions