要查询test表中,name字段不含'/'我这样写
select * from test where name not like '%/%'

解决方案 »

  1.   

    declare @t table([Name] varchar(10))
    insert @t select 'adad/adad'
    insert @t select 'ad'
    insert @t select '456'
    insert @t select '/'
    select * from @t where [Name] not like '%/%'
    select * from @t where charindex('/',[name])<=0
    select * from @t where patindex('%/%',[Name])<=0
    效率都差不多
      

  2.   


    charindex('/',name)<=0 --建议用这个
    select * from @t where [Name] not like '%/%' --肯定是最差的
    select * from @t where charindex('/',[name]) <=0 
    select * from @t where patindex('%/%',[Name]) <=0  --这个还可以 但是用%就不好了_还可以接受
      

  3.   

    charindex('/',name)<=0 這個好