Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Searching for the last six digits
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01571435
Message ID:
01571442
Vues:
40
>>>>I need to do a SQL command which will search on a field which has 15 characters but the user will enter the last six digits only. So, basically, the first 9 characters are not entered and I must find the record matching the last six digits. I usually do the opposite with the % character at the end combined with a LIKE. Anyone has an example on this type of search?
>>>
>>>Well, you can use % in front or use
>>>
>>>select .. from myTable where RIGHT(Column,6) = @Last6
>>>
>>>May perform marginally better
>>>
>>>select .. from myTable where Column LIKE '%' + @Last6
>>
>>Those or the way I was thinking of doing it - but wouldn't that be really slow because there is no matching index? And if so, is it possible to make an index like that?
>
>You can have a computed column with last 6 characters and make an index on this computed column.

doh! I miss the obvious sometimes...hahahaha
ICQ 10556 (ya), 254117
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform