Wednesday, March 7, 2012

need a simple query

select * from table1
where stringname in '%^<>:/\|*?,''%'
I need to search for all the characters above. How do i do it? Thank you.On Tue, 2 May 2006 08:17:02 -0700, tpp <tpp@.discussions.microsoft.com>
wrote:

>select * from table1
>where stringname in '%^<>:/\|*?,''%'
>I need to search for all the characters above. How do i do it? Thank you.
Are you testing the string for...
All those characters?
Any one of those characters? (One character long.)
One or more of those characters, among others?
Any combination of those characters?
Nothing but those characters?
Something I didn't think of?
Assuming for the moment that you want to test for any of those
characters occuring anywhere in the string:
WHERE stringname LIKE '%[%^<>:/\|*?,'']%'
I noticed that % appears twice, once at the beginning and again at the
end. This looks as though you were trying LIKE. I assumed that % was
one of the special characters you were searching for and included it
inside the square brackets.
Note that some special characters % _ [ ] ^ have special meanings in a
LIKE string, and searching for them can be problematic.
Roy Harvey
Beacon Falls, CT|||Hi, tpp
I'm not sure what you are trying to do:
a) select the rows that contain one or more of the following
characters: <>:/\|*?"
SELECT * FROM table1 WHERE stringname LIKE '%[<>:/\|*?"]%'
b) select the rows that do not contain any of those characters
SELECT * FROM table1 WHERE stringname NOT LIKE '%[<>:/\|*?"]%'
Razvan|||Just using like and escaping the characters with [] should do the trick...
Make sure you place the ^ at the end of the string, since it has its own
function.
Look up escape characters in BOL for more info
select * from table1
where strname like '%[<>:/\|*?,''^]%'
"tpp" <tpp@.discussions.microsoft.com> wrote in message
news:9CE6A4CB-9DB6-4443-B884-23CB2E2D826B@.microsoft.com...
> select * from table1
> where stringname in '%^<>:/\|*?,''%'
> I need to search for all the characters above. How do i do it? Thank you.|||Just change 'in' with 'Like' in your query.
But I am not too sure what are you trying to do/achieve? May be you need to
explain more on your query.
Best Regards
Vadivel
http://vadivel.blogspot.com
"tpp" wrote:

> select * from table1
> where stringname in '%^<>:/\|*?,''%'
> I need to search for all the characters above. How do i do it? Thank you.|||I should add that I assumed you wanted values that contained ANY of the
characters in your list, and the % was NOT one of the characters you were
searching for.
"Jim Underwood" <james.underwoodATfallonclinic.com> wrote in message
news:OhNNC%23fbGHA.3320@.TK2MSFTNGP04.phx.gbl...
> Just using like and escaping the characters with [] should do the
trick...
> Make sure you place the ^ at the end of the string, since it has its own
> function.
> Look up escape characters in BOL for more info
> select * from table1
> where strname like '%[<>:/\|*?,''^]%'
>
>
> "tpp" <tpp@.discussions.microsoft.com> wrote in message
> news:9CE6A4CB-9DB6-4443-B884-23CB2E2D826B@.microsoft.com...
you.
>|||I'm sorry i created quite some confusion. i need to search for any string
that contains any one of the characters included in '%^<>:/\|*?,''%'
Yes, I need to use like. And yes, the '%%' in the string is for like... I
hope this clarifies the question a bit more. thanks and again, sorry for the
confusion

No comments:

Post a Comment