Search for all words in a table column that any of the words start with a certain letter

I have products table. Each row has a Description which may have a few words within it. I wanted to know if it's possible to search through it and find all descriptions that have match the search. But, I want it to consider it a match even if it's not the
first word of the description, but rather the start of any word in the description.
For example:
Descriptions
Nice Casual Gloves(This should show up, and although it's not in the very beginning of the description it's at the beginning of a new word.)
Nice Dressy Gloves(This should show up, and although it's not in the very beginning of the description it's at the beginning of a new word.)
Great Dresses (This should show up)
Fancy Outerwear
Glasses (This should show up)
Shoes
Sheer Stockings (This should not show up because although it has a "g" it's not in the beginning of a word.)
Boots
Galoshes (This should show up)
I would want to search within this list Where Description like 'G%' but I don't want it to only get the descriptions that start with "g" at the beginning of the description, but rather any "g" at the beginning of any word. I do not want
to get all descriptions that have a "g" somewhere in the word (then I could just do WHERE DESCRIPTION LIKE '%g%'), rather only if it somewhere within the description but at the beginning of any word.
Thank you so much
Debra has a question

The most perfect solution would be to get a CLR routine to either (a) Do a regular expression match, (b) Run a split routine at CLR speeds then do a simple LIKE, or (c) both (a) and (b).  If your requirements grow to handle more and more complex searches,
you may have to do it that way eventually.
However, like the other answers, here's a way to do it reasonably well given your current requirements.  You may have to tweak the REPLACE logic if you have frequent OTHER forms of word delimiters.
Method:  Pull data; add space before and after original text; replace all common word separators other than space with a space (so for example, "(These pretzels)", "He said 'These pretzels are making me thirsty" and so forth would
be replaced with a space before "The"; then do a Patindex (you could do with just a LIKE also) on the search string prefaced with a space.  Here's an example, stealing from table sys.messages just for ease of demonstration.
With SampleData as
Select top 100 *
, ' ' + Replace(Replace(Replace(Replace(text, '"', ' '), '''', ' '), '/', ' '), '(', ' ') + ' ' as TextPlus
from sys.messages
where language_id = 1033
Select TextPlus
, patindex('% The%', textplus)
from SampleData
where patindex('% The%', textplus) > 1
Same logic, in the most concise format:
Select top 100 Text
from sys.messages
where language_id = 1033
and ' ' + Replace(Replace(Replace(Replace(text, '"', ' '), '''', ' '), '/', ' '), '(', ' ') + ' ' like '% the%'

Similar Messages

  • I have a column of names, some DO NOT start with a capital letter, how do I filter them

    new to Mac environment and i have a column of names, some DO NOT start with a capital letter, how do I filter them

    HI PTU,
    You can mark the rows starting with lower case letters using a formula, then filter on the contents of the column containing the formula. For the example below, the names are in column B and the formula is in column C.
    C2: =IF(AND(CODE(B)>=95,CODE(B)<=122),"!!!","")
    CODE returns the ASCII code for the first character in the target cell. Lower case letters have ASCII codes in the range specified in the formula: a = 95, z = 122
    For names starting with characters in this range, the forula returns a string of three exclamation points. For any other initial character, the formula returns a null string ( "" ).
    An empty cell in column B will cause the formula to return an error in that row of column C. You can avoid this by embedding the formula in an IF statement that suppresses the calculation if the length of the entry in column B is less than one character. Revised formula shown below.
    C2: =IF(LEN(B)<1,"",IF(AND(CODE(B)>=95,CODE(B)<=122),"!!!",""))
    Regards,
    Barry

  • How to search for a word in a text editor

    Hi,
       I have created a custom container and added some text to it. Is there any method to search for words in this?

    Lilan,
    To search a character field for a particular pattern, use the SEARCH statement as follows:
    SEARCH <c> FOR <str> <options>.
    The statement searches the field <c> for <str> starting at position <n1>. If successful, the return code value of SY-SUBRC is set to 0 and SY-FDPOS is set to the offset of the string in the field <c>. Otherwise, SY-SUBRC is set to 4.
    The search string <str> can have one of the following forms.
    <str>
    Function
    <pattern>
    Searches for <pattern> (any sequence of characters). Trailing blanks are ignored.
    .<pattern>.
    Searches for <pattern>. Trailing blanks are not ignored.
    *<pattern>
    A word ending with <pattern> is sought.
    <pattern>*
    Searches for a word starting with <pattern>.
    Words are separated by blanks, commas, periods, semicolons, colons, question marks, exclamation marks, parentheses, slashes, plus signs, and equal signs.
    <option> in the SEARCH FOR statement can be any of the following:
    ABBREVIATED
    Searches the field <c> for a word containing the string in <str>. The characters can be separated by other characters. The first letter of the word and the string <str> must be the same.
    STARTING AT <n1>
    Searches the field <c> for <str> starting at position <n1>. The result SY-FDPOS refers to the offset relative to <n1> and not to the start of the field.
    ENDING AT <n2>
    Searches the field <c> for <str> up to position <n2>.
    AND MARK
    If the search string is found, all the characters in the search string (and all the characters in between when using ABBREVIATED) are converted to upper case.
    Pls. Mark

  • Can iTunes search for all music on my system and rebuild the library?

    Is there any way to make iTunes search for all music on my hard drive and completely rebuild the library from scratch?
    Thanks.

    do you know how to re-locate files to an existing library?
    All of a sudden, about 2/3 of my songs (over 6,000) will not play and a box comes up saying "The song 'x' could not be used because the original file cannot be found. Would you like to locate it?"
    I went to Edit > Preferences > Advanced and have the correct (fixed) external drive letter selected for the folder location. and the files haven't moved, but iTunes isn't finding them. Restarted the computer making sure the drive was on.
    I'd like to not lose all the ratings I've worked on. Hoping you or someone has a solution!!
    thanks!

  • How do I search for a word through multiple files in my directories ??

    Hello everyone
    How do I search for a word through multiple files in my directories ??
    I am guessing one tedious way to do it would be to pass all the file names as command line arguments but I"m sure there exist a much easier and faster way to do it.
    Thanks a lot

    You need to pass only the directory name as parameter and then retrieve the files(recursively throug subdirs or not, however you wish) of that directory.
    There were at least 2 threads yesterday on how to retrieve files from directory, and there are many others in the archive so I leave the search part to you ;)
    HTH
    Mike

  • How to make pdf's searchable for all words for multiple documents?

    I scan hundreds of documents every week at work. These documents are mostly field invoices for industrial work. I have been saving them with the most important/most searched information as the file name so I can search that information from anywhere in my computer and easily find it. As the work we are doing and our customers are becoming more complex I am needing to search for documents by keywords that just would not be efficient to include all into the file name. I have tried OCR to no avail. After doing OCR on many many files, I will try to search for a word that is right in front of me and it says zero found. My ideal: to be able to search my computer from my desktop for a keyword (like I can with word or excel dosuments), and have all pdf's containing that keyword to populate. I have been working on this for far too long and am not finding the solution, so before I set out to find a new program instead of Adobe I'm hoping there is something out there I just don't know about yet. I have googled this issue til my fingertips are bruised and it always brings me back to: Use OCR! Not only hasn't  it found any pdf using keywords (unless I have that specific document open), half of my files it gives me an error message stating those files can not be rendered OCR. The whole point of what I'm trying to do is to ensure I find EVERY SINGLE document that would have the keyword.
    Please help! Thank you!!

    So, park the PDFs that hold those scanner output images of text.
    Now, using Acrobat Pro  create an Action to OCR these PDF files and save.
    Having been OCR'd these PDFs can have a Catalog index of the collection (built with Acrobat Pro).
    Using the Catalog index you can use advanced search (the includes Boolean search).
    Be well...

  • How to search for all files w Metadata mismatch?

    I Upgraded recently from LR2.6 to 3.3.
    Many of my images have an Exclamation Mark on them, following the upgrade, informing me that there is a Metadata Mismatch...
    When I click on it I get this Dialogue box:
    Firstly I think LR developers are playing with potentially important information with a lack of care and consideration. I looked at the metadata in 'File Info' in Photoshop before clicking anything: the creation date was the date the file was created and much of the camera data was missing. After I clicked Overwrite Settings all the original data was back on the file. I have no idea how this came to pass exactly, but it shows metadata is an easily lost thing.
    If Adobe care about their customers I would think they would make it more clear what was at stake here!
    Secondly I would like to know if there is a way to search for all images with this issue to save me having to go through and do it one by one, possibly thousands of times?
    Thnaks Peter

    areohbee wrote:
    Beat,
    Please share the SQL statement.
    select    ''    
             ,LibraryRootFolder.absolutePath || LibraryFolder.pathFromRoot || LibraryFile.lc_idx_filename    as    fullFileName
             ,Image.sidecarStatus
             ,AdditionalMetadata.externalXmpIsDirty
        from      Adobe_images                 as    Image
                 ,AgLibraryFile                as    LibraryFile
                 ,AgLibraryFolder              as    LibraryFolder
                 ,AgLibraryRootFolder          as    LibraryRootFolder
                 ,Adobe_AdditionalMetadata     as    AdditionalMetadata
        where     Image.rootFile                =    LibraryFile.id_local
          and     LibraryFile.Folder            =    LibraryFolder.id_local
          and     LibraryFolder.rootFolder      =    LibraryRootFolder.id_local
          and     AdditionalMetadata.image      =    Image.id_local
          and    (Image.sidecarStatus            not in    (0, 7)
           or     AdditionalMetaData.externalXmpIsDirty     >     0)
        order by    fullFileName
    I am not sure what the meaning of different values in column sidecarStatus and externalXmpIsDirty mean. This is what I've found out by trial and error:
    sideCarStatus = 1 seems to mean "Settings have changed in Catalog compared to XMP"
    sideCarStatus = 7 seems to be OK
    externalXmpIsDirty = 1 seems to mean "Settings have changed in XMP compared to Catalog"
    sideCarStatus = 1 AND externalXmpIsDirty = 1seems to be a Metadata Conflict
    The meaning of sideCarStatus > 1 is unknown to me
    I usually run the query and then look at the single images reported in LR.
    IMHO, this metadata matching is one of the weaker points in LR. I have encountered several conflict situations where I can be 100% sure I have not changed anything on the image outside of LR, and I have "Automatically write Changes to XMP" active. So a conflict should never arise.
    Beat Gossweiler
    Switzerland

  • Searching for a word or phrase in a file on NSS Pool/Volume

    I have encountered a strange issue in that if I search for a word or phrase in a file at any level of the volume, from the root, down to sub folders, I get different results from 2 or more PC's.
    Workstations are all Win XP SP2, Novell Client 4.91 SP4 for Windows
    Server NW 6.5 SP6 with all post SP's installed.
    I have ran a nss /PoolRebuild=POOLNAME and a NSS /VisibilityRebuild=VOLNAME
    There is only one volume on this pool.
    And I still encounter the same results.
    As one example:
    On my Admin workstation When I search the top level Folder of Closed Client folders for the word chronology, I get 2 files returned named chronfile1 and chonfile2, when I search from any other workstation (I have tried 4 different workstations at this point) at the same folder level, for the same word Chronology, I get multiple files with the Word in the File, but I do not see files chronfile1 or chronfile2. Likewise, the file names returned form the search results on the other workstations, are not returned in the search list ran on the admin (Mine) workstation. And yes, I am logged in as admin on the other workstations when running the search.
    So far, this issue is only appearing on 1 volume.
    Thoughts?

    Originally Posted by ataubman
    If you log in to the second PC as Admin, does the symptom move? IOW does it follow the user or the workstation? If the user you may have some odd file system rights set, although your specific results you report are puzzling.
    I'm assuming you are using the Windows desktop search tool?
    I ran a NSS /PoolRebuild last night which fixed an issue the workstations not being able to see the 2 files in question.
    Previous night I had just performed an NSS /PoolVerify.
    Part of the other anomoly, the other workstations seeing more files than the admin workstation (I feel so Stupid, after 25 years you think I'd be able to spot the obvious) the reason the other workstations were returning files that the Admin workstation was not - Admin workstation doesn't have Word Perfect installed.
    Somebody, give me a Gibbs head slap, now!

  • Search for multiple words in a field?

    is there a way to search for multiple words in a field? for example, if i have a metadata field called NOTES that contains the string "Joe and Bob created this version on Sunday" is there a way to search for "Sunday, Joe, Bob" and have it return the asset?

    Search using the "Matches Word" option instead of "Contains". That will limit your results to only assets that have a field value that includes all three of those terms. If they are not all included in the same field value, it will not return a hit. So if "Sunday" were in Keywords and "Joe" & "Bob" are in Notes, you would not get a hit for that search with "Matches Word".
    "Contains" searches for the contiguous string in any field on the assets.
    Further, if you add your Notes field to the Metadata Group "Asset Filter", it will appear in your advanced search options, asset subscription filters, and search expired responses. Then you can specifically limit the search to that field and choose from "Matches Word', "Contains", and several other search filters. Note that when you use "Matches Word" this way, you need to eliminate spaces from your comma delimited list of words or you will not get the search hits you want.

  • Search for all emails by [search person] with an attachment

    how can you search for all emails with an attachment? it's difficult sifting through emails to find that one word doc that someone sent

    Scroll to the top of the mailbox you want to search and enter your search in the Search box

  • How do I search for all "missing" tracks within the iTunes database?

    I found the dreaded ! of death, and sadly I verified the tacks indeed are not on my hard drive.
    Is there a way to sort on this tag so that I can see what else might be missing on my hard drive but remains in the database (sort of similar to how you can search for all tracks that have missing artwork)? 

    Thanks.  It works perfectly.
    URL for anyone else in need:  http://dougscripts.com/123

  • Windows 8.1 PC, using reader, when searching a folder containing approx 100 doc's. If i search for a word, no results are returned. only the doc names can be found but nothing from within the doc. This is a new problem and was not the case before.

    Windows 8.1 PC, using reader, when searching a folder containing approx 100 doc's. If i search for a word, no results are returned. only the doc names can be found but nothing from within the doc.
    This is a new problem and was not the case before.

    Works perfectly fine for me with the latest Reader version (11.0.09).
    You write that it worked "before"; before what?  An update?  Update from what version to what version?

  • Tell me Logic for search for duplicate words(or strings) in a large file.

    Search for duplicate words (or strings) in a text file containing one word per line. For each word that occurs more than once in the flat file output should be as follows
    <word> <number of occurrences> <line numbers in the file where the word occurs>
    For example, if the word Hello occurs thrice in a file at lines 100, 178 and 3456 the output should read
    Hello, 3, [100, 178, 3456]

    Incidentally i wrote similar code some days back. You need to do some modifications to get the exact output you want, but i hope it will be of some help.
    One more thing its written using JAVA5
    public class Test
         private static final String COLLECTIONS_TEXT = "C:\\Documents and Settings\\amrainder\\Desktop\\Collections.txt";
         public static void main(String[] args) throws IOException
              findDuplicateWords();
         private static void findDuplicateWords() throws IOException
              Collection<String> words = new LinkedHashSet<String>();
              File file = new File(COLLECTIONS_TEXT);
              StreamTokenizer streamTokenizer = new StreamTokenizer(new FileReader(file));
              int token = streamTokenizer.nextToken();
              while(token != StreamTokenizer.TT_EOF)
                   if(token == StreamTokenizer.TT_WORD)
                        words.add(streamTokenizer.sval);
                   token = streamTokenizer.nextToken();
              System.out.println(words);
    }Cheers,
    Amrainder

  • How to search for all PDF files on my hard drive

    How can I search for all of a file type on my hard drive without getting documents that happen to have the text in them?  i.e. PDF or DOC or XLS
    Thank you
    Peg

    Put the search term in quotes, and do not forget the .  (dot)
    Results (partial list) of Spotling search for ".pdf". There is a section listing PDF documents.

  • Search for all user messages doesnot work now ?

    Hello SDNer's,
    I often search my own questions and posts entering the keywords in Search for all user messages. After our forum has been revamped this functionality seems not be working as it used to. When I enter the keywords and Enter it throws me results from Expert Forums instead showing results just from my ID/Username.
    Have anyone noticed this ?
    Please comment Mods.
    Happy New Year to all SDNer's !!!

    User search and monitoring was all disabled due to Privacy issues.

Maybe you are looking for