create proc xx
@参数 varchar(100)
as
select * from 表 where 列 like '%'+@参数+'%'

解决方案 »

  1.   

    现在是这样的情况!
    CREATE PROCEDURE B_Num_Sp @bookname varchar(80) AS select * from B_in_tbl where bookname like '%'+@bookname+'%'select bookno,bookname,sum(innum) as innum,0 as jie,0 as hua,0 as storenum,0 as wqnum
    into #t1
    from b_in_tbl
    where bookname = @bookname
    group by bookno,booknameselect bookno,bookname,sum(shu) as jie
    into #t2
    from B_lend_Tbl
    where lendtype = '借出' and bookname = @bookname
    group by bookno,booknameselect bookno,bookname,sum(shu) as hua
    into #t3
    from B_lend_Tbl
    where lendtype = '还入' and bookname = @bookname
    group by bookno,booknameselect bookno,bookname,sum(storenum) as storenum
    into #t4
    from B_Out_Tbl
    where  bookname = @bookname
    group by bookno,booknameupdate #t1
    set jie = b.jie
    from #t1 a,#t2 b
    where a.bookno = b.booknoupdate #t1
    set hua = b.hua
    from #t1 a,#t3 b
    where a.bookno = b.booknoupdate #t1
    set storenum = b.storenum
    from #t1 a,#t4 b
    where a.bookno = b.booknoselect a.InvoiceName,a.bookno,a.InDate,a.InvoiceNo,a.BookNo,a.BookName,a.namebook,a.Writer,a.PubProvName,a.PubDate,a.PubTime,a.PrintDate,a.PrintTime,a.PrintNum,a.PageNum,a.WordNum,a.ISBN,a.Price,b.innum,b.jie,b.hua,b.storenum,(b.innum - b.jie + b.hua - b.storenum) as wqnum
    from b_in_tbl a,#t1 b
    where a.bookno = b.bookno
    GO
    这是我写的存储过程!其中要是按你的模糊的方法会出现无法统计数字的情况!还有很多的小毛病!pengdali(大力 V2.0)帮忙
      

  2.   

    统计数字?select 1 where 134 like '%2%'select 1 where 134 like '%3%'select 1 where 134 like '%4%'select 1 where 134 like '%-%'
      

  3.   

    把 where bookname = @bookname 
    改成 where bookname like '%' + @bookname + '%'
    or charidnex(@bookname,bookname) > 1
      

  4.   

    把 where bookname = @bookname 
    改成 where bookname like '%' + @bookname + '%'
    或 where charidnex(@bookname,bookname) > 1