Invalid Object Name sql

110,919

Solution 1

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.

Solution 2

Try:

Edit -> IntelliSense -> Refresh Local Cache

Solution 3

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.

Solution 4

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

Solution 5

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])
Share:
110,919
user3814197
Author by

user3814197

Updated on July 09, 2022

Comments

  • user3814197
    user3814197 almost 2 years

    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')
    
    • Phil
      Phil almost 10 years
      Which DBMS? Where do you see these errors?
    • Martin Smith
      Martin Smith almost 10 years
      Probably you need to refresh the intellisense cache assuming SSMS.
    • user3814197
      user3814197 almost 10 years
      relational dbms using sql server management studio
    • user3814197
      user3814197 almost 10 years
      tried a refresh of the intellisense cache, but had no impact
    • Aelian
      Aelian over 9 years
      Had the same problem and refreshing intellisense cache as mentioned here worked for me in SSMS.
    • Yusuf Uzun
      Yusuf Uzun almost 8 years
      Don't forget to set user's default schema, if you have any schema over tables.
    • Baljeet Singh
      Baljeet Singh over 4 years
  • Tom Wilson
    Tom Wilson almost 9 years
    Nice and simple for a developer who doesn't use a DB in their normal course of work. Works for me - thanks.
  • Sev09
    Sev09 over 7 years
    "Ctrl + Shift + r" is a shortcut for this, as well.
  • Ganesh Kamath - 'Code Frenzy'
    Ganesh Kamath - 'Code Frenzy' over 6 years
    Thank you. I really appreciate you leaving this answer in this discussion.
  • Nico Haase
    Nico Haase over 6 years
    Is this related to the question in any way?