if keyword=''
begin
select * from tablename
end
else
begin
select * from tablename where condition
end

解决方案 »

  1.   

    create procedure sp_test(@keyword varchar(100))
    as
    begin
        if @keyword is null
            select * from tabname
        else
            select * from tabname where colname like '%'+@keyword+'%'
    end
    go
      

  2.   

    不知道你说的调用页面是什么?create table ziLiao(
    id int identity,
    title varchar(10),
    lastnew datetime
    )insert into ziLiao values('TEMP','2005-7-10')
    insert into ziLiao values('T','2005-7-1')
    insert into ziLiao values('T2','2005-7-1')create proc pr_select(
    @keyword varchar(10)=null
    )
    as
    select * from ziLiao
    where ziLiao.title=@keyword or @keyword is null
    go--三种调用方式:
    execute pr_select
    execute pr_select null
    execute pr_select 'T2'
      

  3.   

    create proc youproc(
    @skeyword int)
    as
      select & from tt
      where keyword=@skeyword
       or skeyword is null
      

  4.   

    就是asp调用页面,
    希望能有运营成功的例子
    真心谢谢大家!
      

  5.   

    这方面的问题虽然花了我苦赞的400分但是学到了很多知识,
    感谢CSDN的朋友