VS2005中调用存储过程报变量没有定义
代码如下:
............................
IF EXISTS(SELECT * FROM tab_SysProp WHERE LevelOneName=@onematerialname)
begin
update tab_SysProp
set LevelOneName=@onematerialnamenew
where LevelOneName=@onematerialname
end
IF EXISTS(SELECT name FROM sysobjects where name=@tabname)
begin
exec
( '
update '+@tabname+ ' set LevelOneName=@onematerialnamenew
where LevelOneName=@onematerialname
')
end
.............................
第一个更新可以,第二个就不行了报@onematerialnamenew没有定义,谢谢!
------解决方案--------------------exec
( '
update '+@tabname+ ' set LevelOneName=@onematerialnamenew
where LevelOneName=@onematerialname
')
exec
( '
update '+@tabname+ ' set LevelOneName= ' ' '+@onematerialnamenew+ ' ' '
where LevelOneName= ' ' '+@onematerialname+ ' ' ' ')