"I should probably start by saying that I am not a SQL expert," Paul wrote. "Sure, I've written my share of SELECT
statements, plenty of UPDATE
statements, and even a few ALTER
statements, but beyond that... nada."
"Fortunately, we do have a SQL guru at work that I can learn from, and thankfully, his code is right there, in the database. Imagine my delight when I uncovered this 2,045-line snippet of SQL Magic that, so far as my non-expert mind can tell, attempts to split a name like 'HARTLEY JR' into two parts."
--SPLIT consultant SURNAME/FORENAMES SELECT CLINICIAN.clinician_code AS CODE, CLINICIAN.clinician_name AS [NAME], LEN(CLINICIAN.clinician_name) AS LENGTH, RIGHT(CLINICIAN.clinician_name, 4) AS INITS, SPECIALTY.specialty_code AS SPEC_CODE, SPECIALTY.specialty_name AS SPEC_NAME INTO #clin_length FROM CLINICIAN LEFT OUTER JOIN SPECIALTY ON CAST(CLINICIAN.clin_specialty AS VARCHAR) = CAST(SPECIALTY.SPECIALTY AS VARCHAR) ORDER BY LEN(CLINICIAN.clinician_name) DESC SELECT CODE, [NAME], RIGHT(INITS, 1) AS INITIALS, LENGTH AS LENGTH, '1' AS INITS_LENGTH, SPEC_CODE, SPEC_NAME INTO #inits1 FROM #clin_length WHERE SUBSTRING(INITS, 3, 1) = ' ' SELECT CODE, [NAME], RIGHT(INITS, 2) AS INITIALS, LENGTH AS LENGTH, '2' AS INITS_LENGTH, SPEC_CODE, SPEC_NAME INTO #inits2 FROM #clin_length WHERE SUBSTRING(INITS, 2, 1) = ' ' SELECT CODE, [NAME], RIGHT(INITS, 3) AS INITIALS, LENGTH AS LENGTH, '3' AS INITS_LENGTH, SPEC_CODE, SPEC_NAME INTO #inits3 FROM #clin_length WHERE SUBSTRING(INITS, 1, 1) = ' ' SELECT * INTO #all_inits FROM #inits1 UNION SELECT * FROM #inits2 UNION SELECT * FROM #inits3 SELECT CODE, LEFT([NAME], 1) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur3_1 FROM #all_inits WHERE LENGTH = '3' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 2) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur4_1 FROM #all_inits WHERE LENGTH = '4' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 1) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur4_2 FROM #all_inits WHERE LENGTH = '4' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 3) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur5_1 FROM #all_inits WHERE LENGTH = '5' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 2) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur5_2 FROM #all_inits WHERE LENGTH = '5' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 1) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur5_3 FROM #all_inits WHERE LENGTH = '5' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 4) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur6_1 FROM #all_inits WHERE LENGTH = '6' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 3) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur6_2 FROM #all_inits WHERE LENGTH = '6' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 2) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur6_3 FROM #all_inits WHERE LENGTH = '6' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 5) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur7_1 FROM #all_inits WHERE LENGTH = '7' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 4) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur7_2 FROM #all_inits WHERE LENGTH = '7' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 3) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur7_3 FROM #all_inits WHERE LENGTH = '7' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 6) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur8_1 FROM #all_inits WHERE LENGTH = '8' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 5) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur8_2 FROM #all_inits WHERE LENGTH = '8' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 4) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur8_3 FROM #all_inits WHERE LENGTH = '8' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 7) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur9_1 FROM #all_inits WHERE LENGTH = '9' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 6) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur9_2 FROM #all_inits WHERE LENGTH = '9' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 5) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur9_3 FROM #all_inits WHERE LENGTH = '9' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 8) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur10_1 FROM #all_inits WHERE LENGTH = '10' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 7) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur10_2 FROM #all_inits WHERE LENGTH = '10' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 6) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur10_3 FROM #all_inits WHERE LENGTH = '10' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 9) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur11_1 FROM #all_inits WHERE LENGTH = '11' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 8) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur11_2 FROM #all_inits WHERE LENGTH = '11' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 7) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur11_3 FROM #all_inits WHERE LENGTH = '11' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 10) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur12_1 FROM #all_inits WHERE LENGTH = '12' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 9) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur12_2 FROM #all_inits WHERE LENGTH = '12' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 8) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur12_3 FROM #all_inits WHERE LENGTH = '12' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 11) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur13_1 FROM #all_inits WHERE LENGTH = '13' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 10) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur13_2 FROM #all_inits WHERE LENGTH = '13' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 9) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur13_3 FROM #all_inits WHERE LENGTH = '13' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 12) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur14_1 FROM #all_inits WHERE LENGTH = '14' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 11) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur14_2 FROM #all_inits WHERE LENGTH = '14' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 10) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur14_3 FROM #all_inits WHERE LENGTH = '14' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 13) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur15_1 FROM #all_inits WHERE LENGTH = '15' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 12) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur15_2 FROM #all_inits WHERE LENGTH = '15' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 11) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur15_3 FROM #all_inits WHERE LENGTH = '15' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 14) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur16_1 FROM #all_inits WHERE LENGTH = '16' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 13) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur16_2 FROM #all_inits WHERE LENGTH = '16' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 12) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur16_3 FROM #all_inits WHERE LENGTH = '16' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 15) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur17_1 FROM #all_inits WHERE LENGTH = '17' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 14) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur17_2 FROM #all_inits WHERE LENGTH = '17' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 13) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur17_3 FROM #all_inits WHERE LENGTH = '17' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 16) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur18_1 FROM #all_inits WHERE LENGTH = '18' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 15) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur18_2 FROM #all_inits WHERE LENGTH = '18' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 14) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur18_3 FROM #all_inits WHERE LENGTH = '18' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 17) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur19_1 FROM #all_inits WHERE LENGTH = '19' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 16) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur19_2 FROM #all_inits WHERE LENGTH = '19' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 15) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur19_3 FROM #all_inits WHERE LENGTH = '19' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 19) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur20_1 FROM #all_inits WHERE LENGTH = '20' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 18) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur20_2 FROM #all_inits WHERE LENGTH = '20' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 17) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur20_3 FROM #all_inits WHERE LENGTH = '20' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 19) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur21_1 FROM #all_inits WHERE LENGTH = '21' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 18) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur21_2 FROM #all_inits WHERE LENGTH = '21' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 17) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur21_3 FROM #all_inits WHERE LENGTH = '21' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 20) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur22_1 FROM #all_inits WHERE LENGTH = '22' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 19) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur22_2 FROM #all_inits WHERE LENGTH = '22' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 18) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur22_3 FROM #all_inits WHERE LENGTH = '22' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 21) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur23_1 FROM #all_inits WHERE LENGTH = '23' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 20) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur23_2 FROM #all_inits WHERE LENGTH = '23' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 19) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur23_3 FROM #all_inits WHERE LENGTH = '23' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 22) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur24_1 FROM #all_inits WHERE LENGTH = '24' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 21) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur24_2 FROM #all_inits WHERE LENGTH = '24' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 20) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur24_3 FROM #all_inits WHERE LENGTH = '24' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 23) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur25_1 FROM #all_inits WHERE LENGTH = '25' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 22) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur25_2 FROM #all_inits WHERE LENGTH = '25' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 21) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur25_3 FROM #all_inits WHERE LENGTH = '25' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 24) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur26_1 FROM #all_inits WHERE LENGTH = '26' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 23) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur26_2 FROM #all_inits WHERE LENGTH = '26' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 22) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur26_3 FROM #all_inits WHERE LENGTH = '26' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 25) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur27_1 FROM #all_inits WHERE LENGTH = '27' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 24) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur27_2 FROM #all_inits WHERE LENGTH = '27' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 23) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur27_3 FROM #all_inits WHERE LENGTH = '27' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 26) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur28_1 FROM #all_inits WHERE LENGTH = '28' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 25) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur28_2 FROM #all_inits WHERE LENGTH = '28' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 24) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur28_3 FROM #all_inits WHERE LENGTH = '28' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 27) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur29_1 FROM #all_inits WHERE LENGTH = '29' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 26) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur29_2 FROM #all_inits WHERE LENGTH = '29' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 25) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur29_3 FROM #all_inits WHERE LENGTH = '29' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 28) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur30_1 FROM #all_inits WHERE LENGTH = '30' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 27) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur30_2 FROM #all_inits WHERE LENGTH = '30' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 26) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur30_3 FROM #all_inits WHERE LENGTH = '30' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 29) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur31_1 FROM #all_inits WHERE LENGTH = '31' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 28) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur31_2 FROM #all_inits WHERE LENGTH = '31' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 27) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur31_3 FROM #all_inits WHERE LENGTH = '31' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 30) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur32_1 FROM #all_inits WHERE LENGTH = '32' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 29) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur32_2 FROM #all_inits WHERE LENGTH = '32' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 28) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur32_3 FROM #all_inits WHERE LENGTH = '32' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 31) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur33_1 FROM #all_inits WHERE LENGTH = '33' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 30) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur33_2 FROM #all_inits WHERE LENGTH = '33' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 29) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur33_3 FROM #all_inits WHERE LENGTH = '33' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 32) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur34_1 FROM #all_inits WHERE LENGTH = '34' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 31) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur34_2 FROM #all_inits WHERE LENGTH = '34' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 30) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur34_3 FROM #all_inits WHERE LENGTH = '34' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 33) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur35_1 FROM #all_inits WHERE LENGTH = '35' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 32) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur35_2 FROM #all_inits WHERE LENGTH = '35' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 31) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur35_3 FROM #all_inits WHERE LENGTH = '35' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 34) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur36_1 FROM #all_inits WHERE LENGTH = '36' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 33) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur36_2 FROM #all_inits WHERE LENGTH = '36' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 32) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur36_3 FROM #all_inits WHERE LENGTH = '36' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 35) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur37_1 FROM #all_inits WHERE LENGTH = '37' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 34) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur37_2 FROM #all_inits WHERE LENGTH = '37' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 33) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur37_3 FROM #all_inits WHERE LENGTH = '37' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 36) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur38_1 FROM #all_inits WHERE LENGTH = '38' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 35) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur38_2 FROM #all_inits WHERE LENGTH = '38' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 34) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur38_3 FROM #all_inits WHERE LENGTH = '38' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 37) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur39_1 FROM #all_inits WHERE LENGTH = '39' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 36) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur39_2 FROM #all_inits WHERE LENGTH = '39' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 35) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur39_3 FROM #all_inits WHERE LENGTH = '39' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 38) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur40_1 FROM #all_inits WHERE LENGTH = '40' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 37) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur40_2 FROM #all_inits WHERE LENGTH = '40' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 36) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur40_3 FROM #all_inits WHERE LENGTH = '40' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 39) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur41_1 FROM #all_inits WHERE LENGTH = '41' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 38) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur41_2 FROM #all_inits WHERE LENGTH = '41' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 37) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur41_3 FROM #all_inits WHERE LENGTH = '41' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 40) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur42_1 FROM #all_inits WHERE LENGTH = '42' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 39) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur42_2 FROM #all_inits WHERE LENGTH = '42' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 38) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur42_3 FROM #all_inits WHERE LENGTH = '42' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 41) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur43_1 FROM #all_inits WHERE LENGTH = '43' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 40) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur43_2 FROM #all_inits WHERE LENGTH = '43' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 39) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur43_3 FROM #all_inits WHERE LENGTH = '43' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 42) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur44_1 FROM #all_inits WHERE LENGTH = '44' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 41) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur44_2 FROM #all_inits WHERE LENGTH = '44' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 40) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur44_3 FROM #all_inits WHERE LENGTH = '44' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 43) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur45_1 FROM #all_inits WHERE LENGTH = '45' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 42) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur45_2 FROM #all_inits WHERE LENGTH = '45' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 41) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur45_3 FROM #all_inits WHERE LENGTH = '45' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 44) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur46_1 FROM #all_inits WHERE LENGTH = '46' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 43) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur46_2 FROM #all_inits WHERE LENGTH = '46' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 42) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur46_3 FROM #all_inits WHERE LENGTH = '46' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 45) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur47_1 FROM #all_inits WHERE LENGTH = '47' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 44) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur47_2 FROM #all_inits WHERE LENGTH = '47' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 43) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur47_3 FROM #all_inits WHERE LENGTH = '47' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 46) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur48_1 FROM #all_inits WHERE LENGTH = '48' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 45) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur48_2 FROM #all_inits WHERE LENGTH = '48' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 44) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur48_3 FROM #all_inits WHERE LENGTH = '48' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 47) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur49_1 FROM #all_inits WHERE LENGTH = '49' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 46) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur49_2 FROM #all_inits WHERE LENGTH = '49' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 45) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur49_3 FROM #all_inits WHERE LENGTH = '49' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 48) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur50_1 FROM #all_inits WHERE LENGTH = '50' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 47) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur50_2 FROM #all_inits WHERE LENGTH = '50' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 46) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur50_3 FROM #all_inits WHERE LENGTH = '50' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 49) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur51_1 FROM #all_inits WHERE LENGTH = '51' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 48) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur51_2 FROM #all_inits WHERE LENGTH = '51' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 47) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur51_3 FROM #all_inits WHERE LENGTH = '51' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 50) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur52_1 FROM #all_inits WHERE LENGTH = '52' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 49) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur52_2 FROM #all_inits WHERE LENGTH = '52' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 48) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur52_3 FROM #all_inits WHERE LENGTH = '52' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 51) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur53_1 FROM #all_inits WHERE LENGTH = '53' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 50) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur53_2 FROM #all_inits WHERE LENGTH = '53' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 49) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur53_3 FROM #all_inits WHERE LENGTH = '53' AND INITS_LENGTH = '3' SELECT CODE, LEFT([NAME], 52) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur54_1 FROM #all_inits WHERE LENGTH = '54' AND INITS_LENGTH = '1' SELECT CODE, LEFT([NAME], 51) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur54_2 FROM #all_inits WHERE LENGTH = '54' AND INITS_LENGTH = '2' SELECT CODE, LEFT([NAME], 50) AS SURNAME, INITIALS, SPEC_CODE, SPEC_NAME INTO #sur54_3 FROM #all_inits WHERE LENGTH = '54' AND INITS_LENGTH = '3' SELECT * INTO #clin_split FROM #sur10_1 UNION SELECT * FROM #sur10_2 UNION SELECT * FROM #sur10_3 UNION SELECT * FROM #sur11_1 UNION SELECT * FROM #sur11_2 UNION SELECT * FROM #sur11_3 UNION SELECT * FROM #sur12_1 UNION SELECT * FROM #sur12_2 UNION SELECT * FROM #sur12_3 UNION SELECT * FROM #sur13_1 UNION SELECT * FROM #sur13_2 UNION SELECT * FROM #sur13_3 UNION SELECT * FROM #sur14_1 UNION SELECT * FROM #sur14_2 UNION SELECT * FROM #sur14_3 UNION SELECT * FROM #sur15_1 UNION SELECT * FROM #sur15_2 UNION SELECT * FROM #sur15_3 UNION SELECT * FROM #sur16_1 UNION SELECT * FROM #sur16_2 UNION SELECT * FROM #sur16_3 UNION SELECT * FROM #sur17_1 UNION SELECT * FROM #sur17_2 UNION SELECT * FROM #sur17_3 UNION SELECT * FROM #sur18_1 UNION SELECT * FROM #sur18_2 UNION SELECT * FROM #sur18_3 UNION SELECT * FROM #sur19_1 UNION SELECT * FROM #sur19_2 UNION SELECT * FROM #sur19_3 UNION SELECT * FROM #sur20_1 UNION SELECT * FROM #sur20_2 UNION SELECT * FROM #sur20_3 UNION SELECT * FROM #sur21_1 UNION SELECT * FROM #sur21_2 UNION SELECT * FROM #sur21_3 UNION SELECT * FROM #sur22_1 UNION SELECT * FROM #sur22_2 UNION SELECT * FROM #sur22_3 UNION SELECT * FROM #sur23_1 UNION SELECT * FROM #sur23_2 UNION SELECT * FROM #sur23_3 UNION SELECT * FROM #sur24_1 UNION SELECT * FROM #sur24_2 UNION SELECT * FROM #sur24_3 UNION SELECT * FROM #sur25_1 UNION SELECT * FROM #sur25_2 UNION SELECT * FROM #sur25_3 UNION SELECT * FROM #sur26_1 UNION SELECT * FROM #sur26_2 UNION SELECT * FROM #sur26_3 UNION SELECT * FROM #sur27_1 UNION SELECT * FROM #sur27_2 UNION SELECT * FROM #sur27_3 UNION SELECT * FROM #sur28_1 UNION SELECT * FROM #sur28_2 UNION SELECT * FROM #sur28_3 UNION SELECT * FROM #sur29_1 UNION SELECT * FROM #sur29_2 UNION SELECT * FROM #sur29_3 UNION SELECT * FROM #sur3_1 UNION SELECT * FROM #sur30_1 UNION SELECT * FROM #sur30_2 UNION SELECT * FROM #sur30_3 UNION SELECT * FROM #sur31_1 UNION SELECT * FROM #sur31_2 UNION SELECT * FROM #sur31_3 UNION SELECT * FROM #sur32_1 UNION SELECT * FROM #sur32_2 UNION SELECT * FROM #sur32_3 UNION SELECT * FROM #sur33_1 UNION SELECT * FROM #sur33_2 UNION SELECT * FROM #sur33_3 UNION SELECT * FROM #sur34_1 UNION SELECT * FROM #sur34_2 UNION SELECT * FROM #sur34_3 UNION SELECT * FROM #sur35_1 UNION SELECT * FROM #sur35_2 UNION SELECT * FROM #sur35_3 UNION SELECT * FROM #sur36_1 UNION SELECT * FROM #sur36_2 UNION SELECT * FROM #sur36_3 UNION SELECT * FROM #sur37_1 UNION SELECT * FROM #sur37_2 UNION SELECT * FROM #sur37_3 UNION SELECT * FROM #sur38_1 UNION SELECT * FROM #sur38_2 UNION SELECT * FROM #sur38_3 UNION SELECT * FROM #sur39_1 UNION SELECT * FROM #sur39_2 UNION SELECT * FROM #sur39_3 UNION SELECT * FROM #sur4_1 UNION SELECT * FROM #sur4_2 UNION SELECT * FROM #sur40_1 UNION SELECT * FROM #sur40_2 UNION SELECT * FROM #sur40_3 UNION SELECT * FROM #sur41_1 UNION SELECT * FROM #sur41_2 UNION SELECT * FROM #sur41_3 UNION SELECT * FROM #sur42_1 UNION SELECT * FROM #sur42_2 UNION SELECT * FROM #sur43_1 UNION SELECT * FROM #sur43_2 UNION SELECT * FROM #sur43_3 UNION SELECT * FROM #sur43_3 UNION SELECT * FROM #sur44_1 UNION SELECT * FROM #sur44_2 UNION SELECT * FROM #sur44_3 UNION SELECT * FROM #sur45_1 UNION SELECT * FROM #sur45_2 UNION SELECT * FROM #sur45_3 UNION SELECT * FROM #sur46_1 UNION SELECT * FROM #sur46_2 UNION SELECT * FROM #sur46_3 UNION SELECT * FROM #sur47_1 UNION SELECT * FROM #sur47_2 UNION SELECT * FROM #sur47_3 UNION SELECT * FROM #sur48_1 UNION SELECT * FROM #sur48_2 UNION SELECT * FROM #sur48_3 UNION SELECT * FROM #sur49_1 UNION SELECT * FROM #sur49_2 UNION SELECT * FROM #sur49_3 UNION SELECT * FROM #sur5_1 UNION SELECT * FROM #sur5_2 UNION SELECT * FROM #sur5_3 UNION SELECT * FROM #sur50_1 UNION SELECT * FROM #sur50_2 UNION SELECT * FROM #sur50_3 UNION SELECT * FROM #sur51_1 UNION SELECT * FROM #sur51_2 UNION SELECT * FROM #sur51_3 UNION SELECT * FROM #sur52_1 UNION SELECT * FROM #sur52_2 UNION SELECT * FROM #sur52_3 UNION SELECT * FROM #sur53_1 UNION SELECT * FROM #sur53_2 UNION SELECT * FROM #sur53_3 UNION SELECT * FROM #sur54_1 UNION SELECT * FROM #sur54_2 UNION SELECT * FROM #sur54_3 UNION SELECT * FROM #sur6_1 UNION SELECT * FROM #sur6_2 UNION SELECT * FROM #sur6_3 UNION SELECT * FROM #sur7_1 UNION SELECT * FROM #sur7_2 UNION SELECT * FROM #sur7_3 UNION SELECT * FROM #sur8_1 UNION SELECT * FROM #sur8_2 UNION SELECT * FROM #sur8_3 UNION SELECT * FROM #sur9_1 UNION SELECT * FROM #sur9_2 UNION SELECT * FROM #sur9_3
[Advertisement]
BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!