alter proc procname
@keyword varchar(20)
@wherecon varchar(20)
as 
select count(1) as totale from login where 姓名 like '%'+@keyword+'%' and 后加wherecon--不知道楼主的“and 后加wherecon”是什么意思--我估计是这个语句比较的话相关不大,当语句多的时候,才能够体现出两者的差别

解决方案 »

  1.   

    更改:alter proc procname应为create proc procname
    还有,不知道楼主的“count(1)"作何解?
      

  2.   

    create proc procname
      @keyword varchar(20),
      @wherecon varchar(20),
      @totale float output
    as 
       sql语句
      

  3.   

    把count结果作为total输出?
    那楼主没必要用输出参数吧
    create proc procname
    @keyword varchar(20),
    @wherecon varchar(20)
    as 
     select count(*) from staff_inf where 字段1 like @keyword and 字段2 like @wherecon--调用时
    exec procname '参数@keyword的值','参数@wherecon的值'
      

  4.   

    把count结果作为total输出?
    那楼主没必要用输出参数吧
    create proc procname
    @keyword varchar(20),
    @wherecon varchar(20)
    as 
     select count(*) from 表 where 字段1 like @keyword and 字段2 like @wherecon--调用时
    exec procname '参数@keyword的值','参数@wherecon的值'
      

  5.   

    wherecon 是指一些查询条件如
    fd1=1 and ....
      

  6.   

    create proc procname
    @keyword varchar(20),
    @wherecon varchar(20)
    as 
    declare 
    strsql varchar(2000)
    set strsql=''
    strsql='select count(*) from 表 where 字段1 like @keyword and 字段2 like' + @wherecon
    exec strsql