Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
I have written one cursor stored procedure for getting printing employee id one by one.
but i am getting error while executing stored procedure
The query is as folows
alter PROCEDURE SP_CURSOR
as
BEGIN
DECLARE @empid INT
DECLARE @GETEMPID CURSOR
SET @GETEMPID = CURSOR FOR
SELECT empid
FROM testtable
OPEN @GETEMPID
FETCH NEXT
FROM @GETEMPID INTO @empid
WHILE @@FETCH_STATUS = 0
BEGIN
	PRINT @empid
	FETCH NEXT
	FROM @GETEMPID INTO @empid
END
CLOSE @GETEMPID
DEALLOCATE @GETEMPID

end

--EXEC SP_CURSOR

ERROR : Msg 16903, Level 16, State 1, Procedure sp_cursor, Line 1
The "sp_cursor" procedure was called with an incorrect number of parameters

Please help me out
Posted
Updated 26-Jul-11 23:56pm
v2

1 solution

The name sp_cursor conflicts with an internal stored procedure name. Change the name of the procedure and it should work like a charm.
 
Share this answer
 
Comments
Mithun P 27-Jul-11 6:46am    
Super boss.
thanks
[no name] 27-Jul-11 6:52am    
you're welcome.

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