Monday 15 July 2013

sql server - A question about desining a faster algorithm in T-SQL for a CASE that I will be telling -


Here is the case

I have a SQL table that contains only one data column, in which some groups How the table looks here:

  open system sub gr open system sub gr (GM / BTIB (1111) / BTITDBL (2222) / BTVY (4444) / ACSVTYSAG basic soft sub gr basic gentle sub gR (GM / BTIB (1111) / BTUGBL (3333) / BTUGBL (3333) / BTAUSGAG main server line SYS sub-gR (GM_BTIB (1111) _BTITDBL (2222) _BTSY (5555) _ANBOSAG main server sub gr main server sub-G R (GM_BTIB (1111) _BTITDBL (2222) _BTVY (4444) _ANBVTYSAG XTM / YTM SUB GR XTM / YTM SUB GR (GM_ BTIB (1111) _BTUGBL (3333) _BTAU (6666) _BTABAG Card SUB GR (GM_ BTIB (1111) _BTUGBL (3333 ) _BTKOU (7777) _BTBKAG system dev. Deputy gR (GM_BTIB (1111) _BTSGBL (8888) _BTPB (9999) _BBASGAG individual B sub gr individual B sub-gR (GM / BTIB (1111) / BTUGBL (3333) / BTAU (6666) / As you see, some groups have duplicate names such as  
  Personal B. SR GR Individual B. SBR (I gr GR) GM / Bitiaibi (1111) / Bitiugielel (3333) / Bitiau (6666) / Bitibiaisaji  

I want to do, I have to update the short version of "Smuhnamon" Want to "more long version of them" as an example Private B GR , Personalized B SBR (GM / Bitiaibi (1111) / Bitiugielel (3333) / Bitiau (6666) / Bitibiaisaaji will look like the following after updating the table.

  Open Systems SUB (Gr GM / Bitiaibi (1111) / Bitiaiteedielel (2222) / Bitiviwai (4444) / Sisvitisag Open Systems sUB gR (GM / BTIB (1111) / BTITDBL (2222) / BTVY (4444) / ACSVTYSAG basic soft sub-gR (GM / BTIB ( 1111) / BTUGBL (3333) / BTUGBL (3333) / BTAUSGAG Basic Soft Sub Gr (GM / BTIB (1111) / BTUGLL (3333) / BTUGL (3333) / BTUsGAG Main Server Online SES SBR GR (GMBTiB (1111) _B TITDBL (2222) _BTSY (5555) _Nobosag Main Server SBR (GMTBB (1111) _BTITDBL (2222) _BTVY 4444) _ANBVTYSAG Main Server SUB GR (GM-BTIB (1111) _BTITDBL (2222) _BTVY (4444) _ANBVTYSAG XTM / YTM SUB GR (GM_BTIB (1111) _BTUGBL (3333) _BTAU (6666) _BTABAG XTM / YTM SUB GR (GM_BTIB (1111) _BTUGBL (3333) _BTAU ( 6666) _BTABAG card sub gr (GM_BTIB (1111) _BTUGBL (3333) _BTKOU (7777) _BTBKAG system god Deputy GR (GM_BTIB (1111) _BTSGBL (8888) _BTPB (9999) _BBASGAG PERS ONAL B sub-GR (GM / BTIB (1111) / BTUGBL (3333) / BTAU (6666) / BTBISAG individual B sub-GR (GM / BTIB (1111 ) / BTUGBL (3333) / BTAU (6666) / BTBISAG  

There are 9000 records in my table, and I have an algorithm that does, but it works very slowly , Like about 3 minutes to complete the query, although what I'm trying to do is something simple I need a fast algorithm.

Money for help Thanks

Resolving this set-based approach should be relatively simple:

 < Update the code> one set by a.yourfield = b.yourfield yourtable, add your tablets to an INNER B. b.yourfield LIKE a.yourfield + '%' and b.yourfield & lt;> A.yourfield  

This match pattern, but will separate a match in itself - although it is less than ideal and after this process I guess you will duplicate or remove some duplicate Nat and any other discrimination value is not something strange.


No comments:

Post a Comment