D
div zhang
Unregistered / Unconfirmed
GUEST, unregistred user!
目标是,想在存储过程中以参数形式传寄一个数据表的名称,经过查询,返回一个值.
现在,用一下存储过程来实现,但无法工作,报告@ZMID 变量没有定义.
存储过程如下:
create procedure GetZmIDByBH @TableName Varchar(40),@BH Varchar(40),@ID integer output
as
declare @SQLS varchar(200), @ZMID integer
set SQLS = 'select @ZMID =ID from ' +@TableName + ' where ZMBH =''' + @BH + ''''
exec(@SQLS)
set @ID = @ZMID
现在,用一下存储过程来实现,但无法工作,报告@ZMID 变量没有定义.
存储过程如下:
create procedure GetZmIDByBH @TableName Varchar(40),@BH Varchar(40),@ID integer output
as
declare @SQLS varchar(200), @ZMID integer
set SQLS = 'select @ZMID =ID from ' +@TableName + ' where ZMBH =''' + @BH + ''''
exec(@SQLS)
set @ID = @ZMID