Invalid object name SQL Server 2008 R2 - Stored procedure

前端 未结 6 1505
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-24 11:51

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 i

相关标签:
6条回答
  • 2020-12-24 12:23

    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.

    0 讨论(0)
  • 2020-12-24 12:33

    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.

    0 讨论(0)
  • 2020-12-24 12:33

    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

    0 讨论(0)
  • 2020-12-24 12:35

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

    0 讨论(0)
  • 2020-12-24 12:37

    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

    0 讨论(0)
  • 2020-12-24 12:39

    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.

    0 讨论(0)
提交回复
热议问题