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.
| Author |
Topic |
|
pcmech
Starting Member
7 Posts |
Posted - 2003-02-11 : 11:19:06
|
| I have an extensive search page that creates a ‘sql where’ clause that is then run dynamically by a stored procedure to produce the search results.What I am having problems with is in searching one of the fields (lets call it keycode). The database has approx. 250,000 records and each keycode field has a unique string. This string contains codes that determine the records origin etc. I need to search this field for specific values in positions 7, 8 & 9. The users will then have a choice of selecting an appropriate field for each of these positions (remember each field does have the option of ‘all records’ (%) )For example:Data in table-1234567890abcdefg2234567890abcdefg3234567c90abcdefg4234567d90abcdefgNeed to Search positions 7, 8 and 9 for-789Would return-1234567890abcdefg2234567890abcdefgOr Search positions 7, 8 and 9 for-7d9Would return-4234567d90abcdefgI have tried using this - (Right(KeyCode, 9) Like ‘%789’) - but what this doesn’t take into account is the possibility of a search string like ‘%7%9’ or ‘%7%%’ etc. (these would not search the specific positions of 7, 8 and 9.Any ideas on how this might be accomplished?Thanks in advance |
|
|
lane0618
Posting Yak Master
134 Posts |
Posted - 2003-02-11 : 14:04:16
|
| try:substring(keycode,7,3)in your where clause.LaneEdited by - lane0618 on 02/11/2003 14:05:17 |
 |
|
|
|
|
|