学习园地  
我的空间
    日前遇到一个存储过程不能执行带参数的sql语句的问题,如:
    select @Countint=count(id) from [@tablename] where  @strwhere
总提示where 附近有错误.   后来把该句作成字符串执行:
    Set @sqlstr='select @Countint=count(id) from [' +@tablename + '] where ' + @strwhere
但其中的参数@Countint就不能返回.
    后来在网上查到sp_executesql可以执行sql并返回参数,其使用如下:
    exec sp_executesql @sqlstr,N'@Countint int out',@Countint out
这时的@Countint 就是sql的返回值
posted on 2006-09-07 16:16  老虎二哥  阅读(507)  评论(0)    收藏  举报