SQL Server游标错误 [英] SQL server cursor error

查看:92
本文介绍了SQL Server游标错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个游标存储过程,以一张一张地获取打印的员工ID.
但是执行存储过程时出现错误
查询如下所示

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

错误:消息16903,级别16,状态1,过程sp_cursor,第1行
使用错误数量的参数调用了"sp_cursor"过程

请帮我


--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

推荐答案

名称sp_cursor与内部存储过程名称冲突.更改过程的名称,它应该像超级按钮一样工作.
The name sp_cursor conflicts with an internal stored procedure name. Change the name of the procedure and it should work like a charm.


这篇关于SQL Server游标错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆