>>I know I have seen some stuff on here before about this but wasn't paying attention then. I have a contact table with fields for both the first namd and last name plus others of course. I have a form where I want to enter a name and search for all records that this name is LIKE either the first name of the last name. I am using stored procedures. How do I write a stored procedure that would check either first name or last name and return any records that are like those names?
>>
>>A name entry could be "win" and I would want to find "Winsborough" in the last name column.
>>Thanks for any help.
>>Tim
>
>I should have added, I also have a field for "File_As" where the full name would be in there as an organization name or if an individual it would be last, comma first plus middle. If it is easier to just search in one column.
>Tim
The File_As LIKE '%' + @Name + '% is not optimizable. Which query will perform better (the OR with the beginning or the FullName LIKE '%' + ..) is hard to tell and it depends on many factors (table size, existing indexes, etc.)
You may want to run several test with various parameters and check Actual Execution plans.
If it's not broken, fix it until it is.
My Blog