Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Substring searching in SQL

Substring searching in SQL

Scheduled Pinned Locked Moved Database
databasealgorithmsperformancetutorial
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Byteman
    wrote on last edited by
    #1

    In SQLServer 2000 I have a table with 25000 rows 7 columns. One of the columns is a nvarchar of 60. I need to do a substring search on that column and the performance is very poor, 3-10 seconds. The search is done by a stored procedure, for example a search for "John Doe" is implemented in SQL by a simple "LIKE %John% AND LIKE %Doe%". I need the functionality of this kind of query, but it's just too inefficient and slow. Any suggestions or references on improving text searching using SQL would be most appreciated. David

    A G 2 Replies Last reply
    0
    • B Byteman

      In SQLServer 2000 I have a table with 25000 rows 7 columns. One of the columns is a nvarchar of 60. I need to do a substring search on that column and the performance is very poor, 3-10 seconds. The search is done by a stored procedure, for example a search for "John Doe" is implemented in SQL by a simple "LIKE %John% AND LIKE %Doe%". I need the functionality of this kind of query, but it's just too inefficient and slow. Any suggestions or references on improving text searching using SQL would be most appreciated. David

      A Offline
      A Offline
      AndyG
      wrote on last edited by
      #2

      You might want to try setting up Full Text Search. Other than that, if you're searching for "John Doe", wouldn't you want the like to look like this: LIKE '%John Doe%' Andy Gaskell, MCSD MCDBA

      B 1 Reply Last reply
      0
      • B Byteman

        In SQLServer 2000 I have a table with 25000 rows 7 columns. One of the columns is a nvarchar of 60. I need to do a substring search on that column and the performance is very poor, 3-10 seconds. The search is done by a stored procedure, for example a search for "John Doe" is implemented in SQL by a simple "LIKE %John% AND LIKE %Doe%". I need the functionality of this kind of query, but it's just too inefficient and slow. Any suggestions or references on improving text searching using SQL would be most appreciated. David

        G Offline
        G Offline
        Gerald Schwab
        wrote on last edited by
        #3

        Is there an index on the column? Also, what about just using LIKE %JOHN DOE% instead of LIKE %John% AND LIKE %Doe%?

        1 Reply Last reply
        0
        • A AndyG

          You might want to try setting up Full Text Search. Other than that, if you're searching for "John Doe", wouldn't you want the like to look like this: LIKE '%John Doe%' Andy Gaskell, MCSD MCDBA

          B Offline
          B Offline
          Byteman
          wrote on last edited by
          #4

          I'd looked at Full Text Search before, but maybe I missed something... Thanks. The LIKE statement is weird because Searching for "John Doe" is suppose to return matches like "John Jackson" and "Jane Doe". That's the only way I've found to get result.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups