Groups | Blog | Home
all groups > sql server programming > june 2006 >

sql server programming : problem with like [^]



Omnibuzz
6/12/2006 10:50:01 AM
try this

SELECT * FROM @Tab WHERE vc like '10.1.[^.%]'

--
-Omnibuzz (The SQL GC)

http://omnibuzz-sql.blogspot.com/



[quoted text, click to view]
Tracy McKibben
6/12/2006 10:55:23 AM
[quoted text, click to view]

Drop the '%' from your query:

SELECT * FROM @Tab WHERE vc like '10.1.[^.]'
Omnibuzz
6/12/2006 11:17:02 AM
Sorry.. that won't work for 10.1.12.. Wrong solution.
You will have to do it the long way :)

SELECT * FROM @Tab WHERE
vc not like '10.1.%[.]%'
and vc like '10.1.%'

--
-Omnibuzz (The SQL GC)

http://omnibuzz-sql.blogspot.com/



[quoted text, click to view]
aneeshattingal
6/12/2006 11:03:44 PM
SET NOCOUNT ON

declare @tab table(vc varchar(2000))
insert into @tab select '10.1'
insert into @tab select '10.1.1'
insert into @tab select '10.1.2'
insert into @tab select '10.1.1.1'
insert into @tab select '10.1.1.1.1'

The problem is that i need to select only 10.1.1 and 10.1.2 when i put input
as 10.1
If I give input as 10.1 , it should select only records 10.1.1 and 10.1.2

I tried this but not working
SELECT * FROM @Tab WHERE vc like '10.1.[^.]%'

aneeshattingal
6/13/2006 12:11:48 AM
Thank guys , both worked ..

[quoted text, click to view]

AddThis Social Bookmark Button