Hi,I have a relatively large text (about several Million words) from which I need to create a wordlist with frequency count. I have an SQL script with a nested loop: the outer loop goes through each record and the inner loop goes through the current record character by character and finds words (e.g. strings between two spaces). Words are written into a temp table from where frequency is calculated. The script is working as expected but is very slow: it would take an estimated 40h to do this job.Q#1: Is there a way to improve such script?Q#2: Is there any other approach that would be faster? For instance, a kind of isword built in function?CorneliusP.-S. The row count is temporarily set to 10.if exists (select 1 from sysobjects where name='_list1')begin drop table _list1 print '_list1 deleted' endprint'Create table where to copy the words'CREATE TABLE [_list1] ( [words] [varchar] (500) COLLATE SQL_Latin1_General_CP1_CS_AS NULL)declare @sent varchar(50), @word varchar(50), @wl int, @i int, @j int, @r intset @j = 1 -- outer loop counter: row countset @word = '' -- a single word, between two spacesset @r = 10--select @r = COUNT(F1) FROM ESwik -- total # of rows in the input tableSET NOCOUNT ONprint'copy words'while @j < @r +1BEGIN select @sent = F1 from ESwik where id = @j set @wl = len(@sent) -- length of the current row set @i = 1 -- inner loop counter: char count while @i < 2 + @wl BEGIN if substring(@sent, @i,1) <> ' ' set @word = @word + substring(@sent, @i,1) else begin insert into _list1 select @word set @word ='' end set @i = @i + 1 END set @j = @j + 1ENDif exists (select 1 from sysobjects where name='_list2')begin drop table _list2 print '_list2 deleted' endCREATE TABLE [_list2] ( [wcnt] [int] NULL , [words] [varchar] (500) COLLATE SQL_Latin1_General_CP1_CS_AS NULL )INSERT INTO _list2 (wcnt, words)SELECT COUNT (words) AS wcnt, wordsFROM _list1GROUP BY wordsORDER BY COUNT(words) DESC