create procedure proNewSreach
(
@theName varchar(200),
@theHy int,
@theArea int
)
as
select ID,xmName,xmHy,xmArea from zsInfo
where
xmName like '%'+@theName+'%'
or
xmHy like '%'+@theHy+'%'
or
xmArea like '%'+@theArea+'%'
go这段代码错在那里啊?

解决方案 »

  1.   

    create procedure proNewSreach
    (
    @theName varchar(200),
    @theHy int,
    @theArea int
    )
    as
    select ID,xmName,xmHy,xmArea from zsInfo
    where
    (xmName like '%'+@theName+'%')
    or
    (xmHy like '%'+@theHy+'%')
    or
    (xmArea like '%'+@theArea+'%')
    go
    --drop procedure proNewSreach
    proNewSreach @theName = '天河',@theHy = '2',@theArea = '1'服务器: 消息 245,级别 16,状态 1,过程 proNewSreach,行 8
    将 varchar 值 '%' 转换为数据类型为 int 的列时发生语法错误。
      

  2.   

    proNewSreach @theName = '天河',@theHy = 2,@theArea = 1
    也是一样的
      

  3.   

    数据库中xmName是什么类型的?
      

  4.   

    xmHy like '%'+@theHy+'%'
    or
    xmArea like '%'+@theArea+'%'
    这两个不多,int类型的不能用like查询
      

  5.   

    问题解决了,非常感谢 guxingwang(lonelystar)
    也谢谢各位热心帮助。
      

  6.   

    create procedure proNewSreach
    (
    @theName varchar(200),
    @theHy int,
    @theArea int
    )
    as
    select ID,xmName,xmHy,xmArea from zsInfo
    where
    xmName like '%'+@theName+'%'
    or
    xmHy = @theHy
    or
    xmArea = +@theArea这样试一试,看看可不可以
      

  7.   

    create procedure proNewSreach
    (
    @theName varchar(200),
    @theHy int,
    @theArea int
    )
    as
    select ID,xmName,xmHy,xmArea from zsInfo
    where
    xmName like '%'+@theName+'%'
    or
    xmHy = @theHy
    or
    xmArea = @theArea不好意思,上面的不对,试一试这个