Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
i want to compare my value to all words in a particular field using the difference? any suggestions ? I already tried '%McDonalds%' but any suggestions welcome.
tbl1col1Name | col2StateCompany name is McDonalds | NCSELECT col1Name, DIFFERENCE(col1Name, 'McDonalds') AS differenceFROM dbo.tbl1WHERE (DIFFERENCE(col1Name, 'McDonalds') >= 2)ORDER BY difference DESC
jimf
Master Smack Fu Yak Hacker
2875 Posts
Posted - 2009-06-10 : 13:07:38
If you want to see if 'McDonalds' exists in the column1, e.g, 'Old McDonalds Farm', usewhere col1Name like '%McDonalds%', otherwise the two values will never be alike using difference unless they're equal.Jim
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2009-06-10 : 14:09:42
can you explain you requirement? are you looking for wildcard match or fuzzy match?
cwfontan
Yak Posting Veteran
87 Posts
Posted - 2009-06-10 : 14:23:43
quote:Originally posted by visakh16 can you explain you requirement? are you looking for wildcard match or fuzzy match?
well i have a string and I want to find the best match in the databasein the example below the best match would be record 2 [Code] string may be "Dupont wharehouse houston TX"database will havenameCol | cityCol | stateColDupont containers Inc | Houston | TXDupont Wharehouse A | Houston | TXDupont Wharehouse | Chicago | IL[\code]if I can hear your sugestions on how to accomplish this.. that may be better than asking about the logic I have in my head.
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2009-06-10 : 14:26:15
so it seems like what you want is a wildcard search... so in above case you want all results to be returned or best match which is second record?
quote:Originally posted by visakh16 so it seems like what you want is a wildcard search... so in above case you want all results to be returned or best match which is second record?
I would say best match.. and I will have to code some logic in that determines how many out of the 3 fields were matched to consider it a full match..thanks