'like' returns all the records

The following code returns ALL the rows in the table
ALTER PROCEDURE dbo.crdGLSearchTreeSP
( @SearchString as varchar)
AS
SELECT ..., ....
FROM dbo.crdFinanceGrouping
WHERE (RTRIM(FinanceGroupingName) LIKE '%' + @SearchString + '%')

If I replace the @SearchString with a quoted value, eg LIKE '%' + 'REVENUE'+ '%' it returns as expected - the three records where FinanceGroupingName includes the string REVENUE. The RTRIM() was included after reading BOL but it should not be necessary.

I really appreciate some help in limiting the records using LIKE.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories