Kavi, if you are looking to build your own thesaurus file, you can certainly parse a string of synonyms this way, to make the population easier. This technique could be modified to translate an entire table. If you have questions about this, there are some good articles and forum posts already written under the headings PARSE and TALLY TABLE.
I hate to leave you now, but it's midnight here and I have to get some sleep. I'll check back in about nine hours.
I hope this helps.
declare @synonyms table (rowID int identity (1,1), searchword varchar(20), synonymWord varchar(20)
primary key (searchword,rowid))
--------------------------------------------------------------
declare @synonym_list varchar(7900)
declare @sepChar varchar(50)
declare @element varchar(4)
declare @searchword varchar(20)
--------------------------------------------------------------
set @searchword = 'check'
set @synonym_list = 'try out, test, examine, confirm, verify'
set @sepchar = ','
set @synonym_list = @sepChar+@synonym_list+@sepChar
--------------------------------------------------------------
;WITH
L0 AS (SELECT 1 AS C UNION ALL SELECT 1),--2 rows
L1 AS (SELECT 1 AS C FROM L0 AS A, L0 AS B),--4 rows "L0 as A, L0 as B" is just shorthand way to code a cross join
L2 AS (SELECT 1 AS C FROM L1 AS A, L1 AS B),--16 rows
L3 AS (SELECT 1 AS C FROM L2 AS A, L2 AS B),--256 rows
L4 AS (SELECT 1 AS C FROM L3 AS A, L3 AS B),--65536 rows
Tally AS (SELECT TOP 1000 ROW_NUMBER() OVER(ORDER BY C) AS N FROM L4),
syns AS
(select Row_Number() over (order by N) as E,
ltrim(rtrim(substring(@synonym_list,N+1,charindex(@sepChar,@synonym_list,N+1)-(N+1)))) as synWord
from tally
where substring(@synonym_list,N,1) = @sepChar
and N < len(@synonym_list)
)
--
insert into @synonyms
select @searchword,synword from syns
----------------------------------------------
select *
from @synonyms
where searchword = 'check'
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills