It seems you are referring to an IntelliSense error in SSMS. Press SHIFT+CTRL+R to refresh the IntelliSense cache and the error in the SSMS query window should go away.
"Invalid object name" error.
I have a table that exists in the database. When I run "Select * from tablename" , it executes successfully .But when I am running "Insert into tablename values()", it is giving me the below error:
"Invalid object name tablename"
The table exists in the database, but getting "Invalid object name" error.
For Select query, it executes successfully. But for Insert query it is giving "Invalid object name" error.
Please help on resolving this issue.
SQL Server Other
7 answers
Sort by: Most helpful
-
-
Seeya Xi-MSFT 16,586 Reputation points
2021-06-11T08:44:34.76+00:00 Hi @Chaitanya Kiran Buduguru ,
First of all, like the trigger problem mentioned by Olaf, you can check it with the following statement:
use [DatabaseName] go select * from sysobjects where xtype='TR'
Secondly, I suspect it is the problem of the owner of the table.
You can try adding ‘’dbo‘’ between the database and the table name.Best regards,
Seeya
If the response is helpful, please click "Accept Answer" and upvote it, as this could help other community members looking for similar queries.
-
Viorel 122.5K Reputation points
2021-06-08T15:09:00.133+00:00 Maybe start your scripts in Management Studio with a statement like 'use MyDatabase' statement, to make sure that you deal with the right database.
Also make sure that the names are typed correctly. If required, specify the schema, for example: 'insert into dbo.tablename...'.
Probably sometimes you must also have the required access rights.
-
Seeya Xi-MSFT 16,586 Reputation points
2021-06-09T02:57:46.627+00:00 Hi @Chaitanya Kiran Buduguru ,
I have compiled two solutions:
1.Click menu Query, then click 'Change Database'. Select your appropriate database name.
Also, you can run this:
Use [YourDatabaseName]
Then, It can be debugged like this:insert into [database name].[dbo].[table name] values('value1','value2',……) go
2.Once a new SQL Server object is created, the newly created object will not be updated in the IntelliSence Local Cache.
You may also need to refresh the IntelliSense cache.
This can be done by following the menu route: Edit -> IntelliSense -> Refresh Local Cache OR pressing Ctrl+Shift+RBest regards,
Seeya
If the response is helpful, please click "Accept Answer" and upvote it, as this could help other community members looking for similar queries.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. -
Olaf Helper 47,436 Reputation points
2021-06-09T10:26:26.037+00:00 The table name works with SELECT but not with INSERT.
So my guess: There is a faulty trigger on the table causing the error.