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 2012 Forums
 Transact-SQL (2012)
 Does any chunk of a string matches another string

Author  Topic 

ipisors
Starting Member

39 Posts

Posted - 2015-04-17 : 18:25:17
I was wondering if there is any SQL function (before I write one and reinvent the wheel, and/or write one that requires an intensive table scan unnecessarily), here is my basic situation:

I'm going to be querying from one table with a particular column with medication names. I could use something like this which will cover maybe 75% of the cases I want to get:

WHERE MAINTABLE.COLUMN1 IN(SELECT COLUMN2 FROM ANOTHERTABLE)

to see whether they match a list of medications in another table. (Maybe could use an inner join as well).

However that won't be good enough for me, because unfortunately medications are listed in an almost infinite format, for example I may have "Emtricitabine" in ANOTHERTABLE.COLUMN2. However, in the table I am querying, that value may be listed as something totally unpredictable, like "2 MG EMTRICITABINE ORAL SOL"

My matching criteria, then, is going to be the following statement in plain English:

"Any chunk of the [space-delimited] array in MAINTABLE.COLUMN1 must match the single value in ANOTHERTABLE.COLUMN2"

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-04-17 : 18:31:18
If you have spelling variants you can use the fuzzy transforms in ssis.
Go to Top of Page
   

- Advertisement -