Invalid object name SQL Server 2008 R2 - Stored procedure

Sql Server-2008

Sql Server-2008 Problem Overview


I am attempting to alter an existing stored procedure with the command

ALTER 'name_of_stored"procedure'

however the name is highlighted in red noting it is an invalid object. I am able to execute the command successfully however am wanting to know why SQL Server 2008 R2 notes it as an error.enter image description here

Sql Server-2008 Solutions


Solution 1 - Sql Server-2008

It's SSMS, not SQL Server. If it's an error against the database engine you'll know it (it wouldn't execute the command successfully).


Solution
You need to refresh the Intellisense cache (Ctrl + Shift + R). Or you can go to Edit -> IntelliSense -> Refresh Local Cache.

Solution 2 - Sql Server-2008

Create a stored procedure by using CREATE PROCEDURE, not ALTER PROCEDURE.

Solution 3 - Sql Server-2008

Intellisense doesn't refresh as quickly as you create new objects. You need to refresh the cache (Ctrl + Shift + R). Or, maybe, don't rely on Intellisense and only worry if the execution fails.

Solution 4 - Sql Server-2008

I had the same issue, the problem was that I had a select statement from stored proc who's name was similar to table's name, so instead of

  select * from Table_Test

I was writing this in the stored procedure

  select * from Proc_Test --selecting from Stored proc, yikes!!

maybe this helps

Solution 5 - Sql Server-2008

I had the same problem and saw an incredible number of possible answers, some quite exotic. Unfortunately I didn't see this page before finding what worked for me. I thought I would add this even though I believe it serves the same end as refreshing Intellisense. I knew I had done my work right because the stored procedure worked correctly in spite of the error so I finally decided it was not a 'real' error.

I exited SSMS and re-entered and the Invalid Object Name error no longer appeared. I presume that refreshed the Intellisense as well.

Solution 6 - Sql Server-2008

In my case on SQL Server 2014 Express, the stored procedure name value showing this error message

> Invalid object name "SP_NAME"

even if the stored procedure has already been created and executing successfully. But after enable IntelliSense, error was removed and every stored procedure query working fine.

enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPeanutsMonkeyView Question on Stackoverflow
Solution 1 - Sql Server-2008user596075View Answer on Stackoverflow
Solution 2 - Sql Server-2008ELAView Answer on Stackoverflow
Solution 3 - Sql Server-2008VinnieView Answer on Stackoverflow
Solution 4 - Sql Server-2008xameeramirView Answer on Stackoverflow
Solution 5 - Sql Server-2008AlanView Answer on Stackoverflow
Solution 6 - Sql Server-2008user2780371View Answer on Stackoverflow