Invalid object name SQL Server 2008 R2 - Stored procedure
Sql Server-2008Sql 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.
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).
You need to refresh the Intellisense cache (Ctrl + Shift + R). Or you can go to Edit -> IntelliSense -> Refresh Local Cache. Solution
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.