Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Checking either / or of two fields for query
Message
De
06/01/2010 12:22:28
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Versions des environnements
SQL Server:
SQL Server 2008
Divers
Thread ID:
01442422
Message ID:
01442439
Vues:
24
>>>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.

Not a problem in this case since there will not be more than a couple hundred records this time. However I am curious why it would not be optimizable on File_As.
Tim
Timothy Bryan
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform