search all fields

  • I'd like to search all the columns in a table. something like:

    select ID, name from nametable where

    ID=somecriteria or

    name=somecriteria or

    phone=somecriteria

    order by name

    but I'm wondering if there is a quick way to do this for a table that might have 30 columns with different datatypes. Suggestions? or do I just do the necessary conversions and list all the columns in the table. Also, I'm guessing the "or"s will make the query very inefficient, is there a better option?

  • If you are going to search that many columns, and if your table has a large number of rows (millions) - then you might be better off using Dynamic SQL to build the search, depending on what is passed in to a procedure.

    Cheers


    I feel the need - the need for speed

    CK Bhatia

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply