Create proc DelRecorder
@tblname varchar(50),
@tblkey int,
@tblwhere int
as
begin
delete @tblname where @tblkey=@tblwhere
end消息 1087,级别 15,状态 2,过程 DelRecorder,第 7 行
必须声明表变量 "@tblname"。
这样创建,为什么会出错

解决方案 »

  1.   

    begin
    exec('delete '+@tblname+' where '+@tblkey+'='+@tblwhere)
    end
      

  2.   

    Create proc DelRecorder
    @tblname varchar(50),
    @tblkey int,
    @tblwhere int
    as
    begin
    exec('delete '+ @tblname+'  where '+ @tblkey+'='+@tblwhere)
    end
      

  3.   

    begin
    exec('delete from'+@tblname+' where '+@tblkey+'='+@tblwhere)
    end
      

  4.   

    Create proc DelRecorder
    @tblname varchar(50),
    @tblkey int,
    @tblwhere int
    as
    begin
    exec('delete '+@tblname+' where '+@tblkey+'='+@tblwhere)
    end