![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, Is it permissible for the "%" to be entered into data that is stored in columns defined as text or varchar? For example, can the data being stored in a text or varchar column be "Mr. Smith has a 50% interest in the property"? Along the same line of thought, if someone wants to search that text or varchar column for the "%" how do you specify it in the SQL? Select * from <table> where <column> like '%' doesn't work. I've tried '%%' and a lot of other things but I can't make it work. Thanks in advance for your help! Sarah B. Anderson |
#3
| |||
| |||
|
|
Select * from <table> where <column> like '%a\%b%' ESCAPE '\'; ...that will match a string containing a%b Breck |
#4
| |||
| |||
|
|
On Oct 9, 2:14*pm, "Breck Carter [TeamSybase]" NOSPAM__breck.car... (AT) gmail (DOT) com> wrote: Select * from <table> where <column> like '%a\%b%' ESCAPE '\'; ...that will match a string containing a%b Breck Thanks Breck. Is there a way to search for a % sign on its own? In other words, I want to find all rows where <column> contains a "%". Also, is it ok to have the "%" in data in columns that are defined as text or varchar? Thanks again for your help. Sarah B. Anderson |
#5
| |||
| |||
|
|
Also, is it ok to have the "%" in data in columns that are defined as text or varchar? Thanks again for your help. Sarah B. Anderson |
#6
| |||
| |||
|
|
This should work: LIKE '%\%%' ESCAPE '\' The first and last % work like wild cards to match zero or more of any characters, and the middle \% exactly matches a single % character. Breck |
#7
| |||
| |||
|
|
Sarah wrote: Also, is it ok to have the "%" in data in columns that are defined as text or varchar? *Thanks again for your help. Sarah B. Anderson It is ok to store *any* kind of chars in text/char columns - that's what they are for. Your issue has just to do with LIKE search clauses, and you're right that looking for chars that are used as wildcards is a little bit more difficult. However, the solution is not to prevent the storage of such data but to apply the correct escape sequences like Breck has shown. HTH Volker |
![]() |
| Thread Tools | |
| Display Modes | |
| |