>I have created some stored procedures in SQL and they contain indexes. As you know SQL indexes speed up the query. The problem is, at times I want to wrap the field(s) being selected in RTRIM or LTRIM. The proble is this sows down the query, because it does not use the INDEX.
>
> have any of you guys 'Who use SQL server' run into this problem, and if so how did you handle it?
>
> I resorted to useing padding of spaces on the variable passed to SQL. Are there any other solutions?
You can use table or query hints to persuade SQL Server to use a particular index or order. Look up OPTION and INDEX() in the BOL.
Also, take a look at this white paper at MS:
http://www.microsoft.com/SQL/techinfo/administration/70/perftuning.asp