日期:2014-05-19  浏览次数:20590 次

存储过程
代码如下:

............................
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 LevelOneNmae= ' ' '+@onematerialnamenew+ ' ' ' where LevelOneName= ' ' '+@onematerialname+ ' ' ' ')
------解决方案--------------------
IF EXISTS(SELECT name FROM sysobjects where name=@tabname)
begin
exec
( 'update '+@tabname+ ' set LevelOneName= ' ' '+@onematerialnamenew+ ' ' '
where LevelOneName= '+@onematerialname)
end