Click here to Skip to main content
15,891,708 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to execute the following Stored Procedure for the Department table in my DataBase for which i am getting this error.
Msg 208, Level 16, State 6, Procedure Proc_Department_Select, Line 24 Invalid object name 'dbo.Proc_Department_Select'.

Can anybody help me with this?
SQL
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[Proc_Department_Select] 
	@DepartmentID as int=null	
AS
BEGIN	
SET NOCOUNT ON;
IF (@DepartmentID is null or @DepartmentID=0)
BEGIN  
SELECT  d.DepartmentID,
	d.DepartmentName,
	d.PhoneNo
FROM Department d
END

ELSE
BEGIN
SELECT  d.DepartmentID,
	d.DepartmentName,
	d.PhoneNo
FROM Department d
WHERE d.DepartmentID = @DepartmentID
END
END
GO

I've been unable to locate the cause of the error and would appreciate all help..!!

Thank you.
Posted
Updated 16-Jul-10 7:22am
v2
Comments
LNogueira 16-Jul-10 12:27pm    
Post the code where you are calling the stored procedure.

Check the permission of your proc. It is one of the possibilities.
 
Share this answer
 
cnjadhav wrote:
ALTER PROCEDURE [dbo].[Proc_Department_Select]

Change the word 'ALTER' to 'CREATE'!

Currently, the stored procedure doesn't exists in your database. First time you need to use CREATE. Once it is there, use ALTER on further edits if any.
 
Share this answer
 
v2
Comments
cnjadhav 16-Jul-10 13:47pm    
hey Sundeep that was great. it worked for me..

Thankyou for all your Help, Cheer..!!
Sandeep Mewara 16-Jul-10 13:49pm    
Good that it helped you.
Sandeep Mewara 17-Jul-10 0:50am    
You should always marke the answer as accepted if that resolves your issue. This would help you and others in future.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900