select * from A 
where [Name] LIKE '%'+@pName+'%'

where @pName LIKE '%'+[Name]+'%'
有什么区别吗?
个人一直觉得是一样的 糊涂中……
盼答案

解决方案 »

  1.   

    select * from A where [Name] LIKE '%'+@pName+'%' 
    select * from a where charindex(@pName,[Name]) 
    这两没有区别 
      

  2.   

     而且,第一个是NAME 包含 @pName第二个是@pName 包含name
      

  3.   

    select * from A where [Name] LIKE '%'+@pName+'%' 
    select * from a where charindex(@pName,[Name]) >0
    这两没有区别 
      

  4.   

    当然有区别。
    [ ] 指定范围 ([a-f]) 或集合 ([abcdef]) 中的任何单个字符。 WHERE au_lname LIKE '[C-P]arsen' 将查找以arsen 结尾且以介于 C 与 P 之间的任何单个字符开始的作者姓氏,例如,Carsen、Larsen、Karsen 等。 
      

  5.   

    where @pName LIKE '%'+[Name]+'%' 这个要用动态执行
      

  6.   

    一个对[Name]进行模糊查询
    一个对@pName 进行模糊查询
      

  7.   

    --name包含@pname
    select * from A where [Name] LIKE '%'+@pName+'%' --@pname包含name
    select * from A where @pName LIKE '%'+[Name]+'%' 如同A到B,B到A.是两个不同的方向.
    也就是你所说的两个不同的功能
      

  8.   

    create table Inventory2
    (
      [name] varchar(20)
    )
    delete from Inventory2
    insert into Inventory2
    select 'AADDDTTT' union all
    select 'AADDDFFF' union all
    select 'AADD' union all
    select 'AADEFFD' declare @pName varchar(20)
    set @pName = 'AADDDFFF' 
    select * from Inventory2 
    where [Name] LIKE '%'+@pName+'%' name
    --------------------
    AADDDFFF(1 行受影响)select * from Inventory2 
    where @pName  LIKE '%'+[Name]+'%' 
    name
    --------------------
    AADDDFFF
    AADD(2 行受影响)
      

  9.   

    那是不是@pName = [Name] 和 [Name] = @pName就没有区别了?
      

  10.   

    举两个字符串作例子好了
    ABC
    B'B' LIKE '%ABC%' 不成立
    'ABC' LIKE '%B%' 成立
      

  11.   


    这个么区别。 不过你前面那个LIKE是有区别的。