Invalid Object Name - Stored Procedure

invalid object name sql dbo
invalid object name login
invoke-sqlcmd : invalid object name
invalid object name cust
synonym refers to an invalid object
invalid object name contact
could not find stored procedure
could not find stored procedure visual studio

I am creating a stored procedure in SQL Server via SSMS.

I have written the stored procedure below, however when I click execute it am given the error:

Msg 208, Level 16, State 6, Procedure NewQuestion, Line 11 Invalid object name 'hgomez.NewQuestion'.

the table is ownership is correct. (hgomez.Questions)

USE [devworks_oscar]
GO
/****** Object:  StoredProcedure [hgomez].[NewQuestion]    Script Date: 10/23/2011 23:55:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [hgomez].[NewQuestion]
    (
    @QUESTIONNAME nvarchar(50),
    @QUESTION_ID int OUTPUT
    )

AS
    /* SET NOCOUNT ON */
    INSERT INTO [Questions] (QuestionText) VALUES (@QUESTIONNAME)
    SET @QUESTION_ID = SCOPE_IDENTITY();
    RETURN

Thanks in advance


I was a fan of always prepending my CREATE statements with an explicit check for existence and dropping if it was found.

IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'NewQuestion' AND ROUTINE_SCHEMA = 'hgomez')
BEGIN
    DROP PROCEDURE hgomez.NewQuestion
END
GO

-- this is always a CREATE
CREATE PROCEDURE [hgomez].[NewQuestion]
    (
    @QUESTIONNAME nvarchar(50),
    @QUESTION_ID int OUTPUT
    )

AS
    /* SET NOCOUNT ON */
    INSERT INTO [Questions] (QuestionText) VALUES (@QUESTIONNAME)
    SET @QUESTION_ID = SCOPE_IDENTITY();
    RETURN

That can be a bit of hassle with regard to permissions so others use an approach wherein they create a stub method only to immediately ALTER it.

IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'NewQuestion' AND ROUTINE_SCHEMA = 'hgomez')
BEGIN
    EXEC ('CREATE PROCEDURE hgomez.NewQuestion AS SELECT ''stub version, to be replaced''')
END
GO

-- This is always ALTER
ALTER PROCEDURE [hgomez].[NewQuestion]
    (
    @QUESTIONNAME nvarchar(50),
    @QUESTION_ID int OUTPUT
    )

AS
    /* SET NOCOUNT ON */
    INSERT INTO [Questions] (QuestionText) VALUES (@QUESTIONNAME)
    SET @QUESTION_ID = SCOPE_IDENTITY();
    RETURN

Invalid object name SQL Server 2008 R2 - Stored procedure, 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. Your feedback is appreciated. Please tell us how we can make this article more useful. Please provide us a way to contact you, should we need clarification on the feedback provided or if you need further assistance.


This script tries to modify a procedure that already exists; it doesn't create the procedure.

To create the procedure use CREATE PROCEDURE

CREATE PROCEDURE [hgomez].[NewQuestion]

Once the procedure exists, you can modify its definition by using ALTER PROCEDURE

ALTER PROCEDURE [hgomez].[NewQuestion]

Article: "Invalid Object Name" error when calling a Stored procedure, When using the Connect for ODBC SQL Server driver to call a Stored Procedure using the SQL Server syntax, the mentioned error is thrown. possible duplicate of Invalid Object Name - Stored Procedure – Pரதீப் Nov 6 '14 at 7:59 i restart SQL Server and its now working. Possibly the intense issue.


This solution https://stackoverflow.com/a/26775310/2211788 explained

If you drop and re-create a stored procedure it gets a new objectid - the list of stored procedures in SSMS is linked to the id it knows at the time the list was built. If you re-create it but don't refresh the stored procedures folder then any attempts to edit it will indicate the procedure is not found as the id has changed.

Invalid Object Name, Hi, I'm very new to this & trying to create a stored procedure to insert data into my database but I keep getting the above error on the name of my  Invalid Object Name - Stored Procedure. I am creating a stored procedure in SQL Server via SSMS. I have written the stored procedure below, however when I click execute it am given the error: Msg 208, Level 16, State 6, Procedure NewQuestion, Line 11 Invalid object name 'hgomez.NewQuestion'. the table is ownership is correct.


This happened to me once when I had two instances of SSMS open and I was working on the one I opened first. Closed them both down, reopened and it worked fine.

sql server could not find the stored procedure and Invalid object name, SQL server tutorial on fixing "Could not find stored procedure" & "Invalid object name"Duration: 3:57 Posted: Sep 22, 2017 IF OBJECT_ID('Test1') IS NOT NULL DROP PROCEDURE test1 GO -- End batch CREATE PROCEDURE Test1 AS IF Object_id('tempdb.dbo.#temp') IS NOT NULL DROP TABLE #temp SELECT 1 AS test INTO #temp GO -- Ends the CREATE PROCEDURE batch SELECT * FROM #temp


Solved - Invalid object name SQL management studio, Invalid object name SQL management studio. Solved Invalid object temp table in Stored Duration: 1:24 Posted: Nov 19, 2017 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.


INVALID OBJECT NAME – SQLServerCentral, I have wrote one store proc. So, in the stored procedure, it is using one table which is in the different database. When I am trying to execute the  for you to execute i think that the #tmp_table should be created first using a ddl statement. Then you execute your exec and the stored proc you have created in the exec should have the same named temp table viz.#tmp_table.


ERROR: "Invalid object name" - Knowledge Essentials, This typically means 1 of 2 things you've referenced an object (table, trigger, stored procedure,etc) that doesn't actually exist (i.e., you executed a query to  SQL server tutorial on fixing "Could not find stored procedure" & "Invalid object name"