Create procedure ReCount() 
@Cnts Int Output 
AS select @Cnt=count(*) 
from table1 return 
go 

解决方案 »

  1.   


    方法1:
    Create procedure ReCount() 
    AS
    select count(*) from table1 
    return 
    go 调用时:
    set p_rs="调用存储过程ReCount"
    i=p_rs(0)i 就是你要的值。
      

  2.   


    重要更正:上篇方法中的“ReCount”后面应该是没有括号的,也是一个解决方法
    方法2:
    Create procedure ReCount 
    @Cnts Int Output 
    AS select @Cnts=count(*) 
    from table1 return 
    go 
    你的代码至少有如下几个错误:
    1、“ReCount”后面应该是没有括号的;
    2、声明变量为“Cnts”,引用时却误写为“Cnt”;
    3、SQL语句使用不对(语法不熟);两个方法都经过调试通过。
      

  3.   


    select @Cnts=(select count(*)  from table1 )