15

I keep getting an invalid object name error on my sql code. (member_number, subscriber_policy_number) is underlined with the error message.

The code itself runs fine with no errors, why does this happen? None of the code above this is highlighted

update smmdmm.aid_data
set Member_Number = Subscriber_Policy_Number
where Member_Number in ('000000000','000000001')
DineshDB
  • 5,998
  • 7
  • 33
  • 49
user3814197
  • 233
  • 1
  • 3
  • 9

10 Answers10

38

Make sure you're using the correct database. It may be defaulting to the "Master" database, and it doesn't look like you have the full schema for the referenced table.

Ex: [DatabaseName].[Schema].[TableName] or [Database1].[smmdmm].[aid_data]

Hope this helps.

Sev09
  • 883
  • 2
  • 12
  • 27
25

Try:

Edit -> IntelliSense -> Refresh Local Cache
Revanth Kumar
  • 809
  • 12
  • 18
15

According to the error you're receiving I assume that you're using MSSQL.

at the beginning of your queries try:

use [YOUR_DATABASE_NAME];

and then your query. It helped in my case.

kamil.ka
  • 150
  • 1
  • 4
  • Nice and simple for a developer who doesn't use a DB in their normal course of work. Works for me - thanks. – Tom Wilson Sep 02 '15 at 07:48
4

This works for me : Edit -> IntelliSense -> Refresh Local Cache

hoogw
  • 4,982
  • 1
  • 37
  • 33
2

There might be 2 reasons for it.

  1. Table name is wrong

    Sol: Verify the table name and try to execute

  2. Database name and schema name are not mentioned with the table name in query

    Sol: Mention the database and schema name in SQL query.

For ex:

select * from MESQLDBM.dbo.Alert ([DatabaseName].[Schema].[TableName])
Community
  • 1
  • 1
GSK
  • 31
  • 2
1

In my case, I was missing modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();

Daniel
  • 920
  • 1
  • 11
  • 22
0

It happened to me in a function and it was a table within that had been dropped long time ago

Phil50
  • 71
  • 1
  • 2
0

I came to this page as I kept getting this error each time I ran the program, anyway I found that in the settings my SQL string table name was missing the underscore and should have been as follows; tbl_Customer.

0

I faced case sensitivity problem. Below was my erroneous query

SELECT * FROM [bccci$Biochemical View] AS ibv 

here "V"- 1st character of last part of table name is Upper case but in actual table name it was lower case. that is [bccci$Biochemical view]. So my correct code was

SELECT * FROM [bccci$Biochemical view] AS ibv 
Saim Saddat
  • 38
  • 1
  • 1
  • 8
Md. Zakir Hossain
  • 1,082
  • 11
  • 24
0

If you are using VSCode with the mssql plugin, many times the tables you create are not recognized as objects but it is not enough just to update the database.

You need to update the VSCode Intelissense cache.

To do this just close and open VSCode .

The other way is to type the command ctrl+shift+p , which will open the command palette and then type SQL and locate in the MS SQL list: Refresh IntelisSense Cache