Stored procedure parses correctly but will not execute. Invalid object name. Msg 208 Stored procedure parses correctly but will not execute. Invalid object name. Msg 208 database database

Stored procedure parses correctly but will not execute. Invalid object name. Msg 208


Looks like it might not exist yet, swap the Alter to a Create.


To avoid this happening in the furture, do what we do, never use alter proc. Instead we check for the existance of the proc and drop it if it exists, then create it with the new code:

IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'myProc')BEGIN    DROP  Procedure  myProcENDGOCREATE PROCEDURE myProc (add the rest of the proc here)


Here is another solution

USE [PMRS2]GOSET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOIF OBJECT_ID ( 'dbo.YourProcedureName', 'P' ) IS NOT NULL       DROP PROCEDURE dbo.YourProcedureName;  GOCREATE PROCEDURE [dbo].[YourProcedureName] (    @UserName varchar(50),    @Password varchar(50))ASBEGINSET NOCOUNT ON;    select ... (your query)END