I have to apply word correction on a field in my database. Those corrections are french accents that are missing. I have two table, one with the company data and a company name field that might be missing some accents on particular words and a second table with a collection of known word that require accents.
ID CompanyName ID Word
---------------开发者_StackOverflow社区--------------- ---------------------------
1 Jim Desormeaux Electrique 1 Désormeaux
2 Entreprises D Desormiers Inc. 2 Électrique
3 Désormiers
I want to create a query that will seached for the word that match within the companies names in the first table and replace the matching word with the version in the second version. Like this.
ID CompanyName
------------------------------
1 Jim Désormeaux Électrique
2 Entreprises D Désormiers Inc.
Now, I know that I can use the collation "Latin1_General_CI_AI" argument so that the word with accents will match with word without accents. So I could do something like this.
UPDATE C
SET C.CompanyName = REPLACE(C.CompanyName, AWR.Word, AWR.Word)
FROM Companies C
INNER JOIN AccentsWordRepository AWR ON C.ListingName LIKE '% ' + AWR.Word + ' %'
OR C.ListingName LIKE '%' + AWR.Word + ' %'
OR C.ListingName LIKE '% ' + AWR.Word + '%'
The problem here is that this is really slow and i was wondering if there would be a better way to do this.
Thank you.
Few years ago I've to improve performance of a stored procedure which processing a lot of strings, the best results I got by moving out processing logic into a CLR Assembly deployed to Sql Server, not sure whether it would help you but anyway you can give it a try.
Here is an example which I've just found, but surely you can search it yourself
Does SQL Server Full Text Search offer any possible solutions for you? It's been getting progressively better with each version, and it surely must offer something.
http://msdn.microsoft.com/en-us/library/ms142547.aspx
精彩评论