exec @strSQL 好像不是能返回值的,你在sql语句中用了传出值的变量

解决方案 »

  1.   

    declare @out intset @strSQL = 'select @TopicCount=count(TopicID) FROM ForumTopics WHERE ' + @strWhere +';'exec sp_executesql @strSQL,N'@TopicCount int output',@out outputselect @out
      

  2.   

    你就没有声名变量@strSQL 和 @strWhere 呀你可以把你的@strSQL 打印出来看一下,不就清楚了
      

  3.   

    当有输出参数时:用exec sp_executesql
      

  4.   

    use pubs
    declare @sqlwhere varchar(100)
    set @sqlwhere='select * from employee'+char(13)+'select * from ss'
    exec(@sqlwhere)
    这个可不可以
      

  5.   

    xluzhong(打麻将一缺三,咋办?) 
    的方案可用