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)
 Matching Pattern with Like

Author  Topic 

sql_beginner07
Starting Member

1 Post

Posted - 2007-04-20 : 12:38:18
I have this problem with this function (func_a)
IF @strNames LIKE ('%'+ @name+'%')
SET @rtn = 1
ELSE RETURN 0

func_a('BC','ABCD, FFFA, AAAC')

I want it to return 0 . But the problem is %BC% MATCHES WITH ABCD.
I also want BC and BC02/06/05 return true since they are the same group
So any help would be very much appreciated .

Thanks

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2007-04-20 : 13:04:01
Come again?

e4 d5 xd5 Nf6
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-04-20 : 13:27:53
If you had a "search string" of 'BC', and a comparison "list" of 'ABCD,FFFA,AAAC' (not that there are NO embedded spaces unlike your sample), and you wanted to ONLY find whole-value-matches, rather than partial-value matches, you could do:

',' + @strList + ',' LIKE ',' + @strSearch + ','

Kristen
Go to Top of Page

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2007-04-20 : 13:28:32
Look into the patindex() function in sql.


It may be a better choice for this.
Go to Top of Page
   

- Advertisement -