Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 not like

Author  Topic 

funketekun
Constraint Violating Yak Guru

491 Posts

Posted - 2006-11-23 : 16:28:08
declare @table table (tableid int identity(1,1) , t varchar(200))
insert @table
select 'asdf, adsfa, asdf' union all
select 'asdf, adsfa asdf' union all
select 'asdf, asdf' union all
select 'asdf,adsfa, asdf' union all
select 'asdf adsfa asdf' union all
select 'asdf 453 ldlkd ' union all
select 'asdf asdf - asdf --adsf ' union all
select 'asdf , adsfa, asdf' union all
select 'asdf ,adsfaasdf' union all
select 'asdf adsfasdf,' union all
select ',asdf adsfasdf,'

select * from @table where t not like '%,%'


how can i select the records which don't have a comma. i dont wanna use a not like because i read its bad for performance.

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2006-11-23 : 18:45:49
You can try:
select * from @table where charindex(',',t) < 1

In any case you will end up with a full scan of the table,
so performance will probably be about the same.

rockmoose
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-11-24 : 04:15:05
or

select * from @table where replace(t,',','') =t


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -