Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Function in Where clause

Author  Topic 

nvakeel
Yak Posting Veteran

52 Posts

Posted - 2008-02-05 : 08:59:13
Hello,
I have a select query which uses Trim function..like

Select * from Tbl1 where ltrim(name) = @name.

I am using this trim functions very often, the perfomance is hitting low....
can anyone giv me a permanent solution avoiding the trim functions.
It would be of great help.

Thanks.

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2008-02-05 : 09:11:19
Trim the data when you insert it into the database.
Go to Top of Page

nvakeel
Yak Posting Veteran

52 Posts

Posted - 2008-02-05 : 09:22:06
I am Using this select query in SP so I need a query to compensate the trim functions.
Go to Top of Page

Ifor
Aged Yak Warrior

700 Posts

Posted - 2008-02-05 : 10:41:52
The following will allow index scans:

SELECT *
FROM Tbl1
WHERE [name] LIKE '%' + @name


but will allow characters other than space at the beginning.
Go to Top of Page
   

- Advertisement -