|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Can a WHERE CAST() clause use an index??
I've got a table with GUIDs, names, DOB's etc. and want to build a generic search SQL method from a client application.
If I have an index on the primary key and do this search SELECT * FROM TABLE WHERE CAST(uniqueID AS VARCHAR(25)) = '4454'; Will is be able to use the index? I presume not. |
|
#3
|
|||
|
|||
|
Quote:
But would that still be able to use the primary key index which is created using an INTEGER data type? Perhaps I should be more explicit. I want to have a simple Google-like search interface with a single text box to input the search string. I'll parse the query string on white space and use WHERE LIKE commands to filter the rows. Specifically I want to search across INTEGER, VARCHAR and DATE data types. Query string: "SMITH 03/1980" SQL: SELECT uniqueID FROM TABLE WHERE surname LIKE '%smith%' OR surname LIKE '%03/1980%' OR dob LIKE '%smith%' OR dob LIKE '%03/1980%' Result: To return all the entries with surname SMITH and born in March 1980 |
|
#4
|
||||
|
||||
|
there are so many things weird here, i just don't know where to start
the index on your integer primary key (let me guess, IDENTITY?) will be useless indexes on your other columns will also be useless because of the wildcards my sincere advice: redesign your front end interface |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > Can a WHERE CAST() clause use an index?? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|