Despiste some lack of details I manged to create a answer.
If we guess the data is in this format
Create table dbo.[Summary]
(
id int not null
,summary varchar(2000) not null
)
GO
insert into dbo.[Summary]
values
(1, 'asdffgggggg Anand * edkkofffmfmmfmfm Bala sdkdodkekeke Chandra dkkdkd "vinoth"*')
,(2, 'asdffgggggg Dinesh * edkkofffmfmmfmfm Frankin sdkdodkekeke Elisia dkkdkd Ganesh')
,(3, 'asdffgggggg Hansika edkkofffmfmmfmfm [A.Ishwariya]* sdkdodkekeke Jack dkkdkd "Lalitha"')
GO
We first need to clean that messy data this way:
update s
set s.summary = replace(s.summary,'[','')
from dbo.[Summary] s
update s
set s.summary = replace(s.summary,']','')
from dbo.[Summary] s
update s
set s.summary = replace(s.summary,'"','')
from dbo.[Summary] s
while exists(
select *
from dbo.[Summary] s
where charindex(' ',s.summary) > 0
)
begin
update s
set s.summary = replace(s.summary, ' ',' ')
from dbo.[Summary] s
end
update s
set s.summary = replace(s.summary, ' *','*')
from dbo.[Summary] s
Now we get rid of extra spaces and special chars. We need to count the spaces.
Obs: I'm guessing the "structure" fo the data is invariant.
Off course is possible to process variant structures (variant number of names in each row for example) but that's complicated and can needs recursion, loops etc.
declare @Spaces as Table
(
SummaryId int not null
,Space01 int not null
,Space02 int null
,Space03 int null
,Space04 int null
,Space05 int null
,Space06 int null
,Space07 int null
,Space08 int null
)
insert into @Spaces
(SummaryId, Space01)
select s.id, charindex(' ',s.summary)
from dbo.[Summary] s
update sp set sp.Space02 = charindex(' ', s.summary, sp.Space01 +1) from @Spaces sp join dbo.[Summary] s on s.id = sp.SummaryId
update sp set sp.Space03 = charindex(' ', s.summary, sp.Space02 +1) from @Spaces sp join dbo.[Summary] s on s.id = sp.SummaryId
update sp set sp.Space04 = charindex(' ', s.summary, sp.Space03 +1) from @Spaces sp join dbo.[Summary] s on s.id = sp.SummaryId
update sp set sp.Space05 = charindex(' ', s.summary, sp.Space04 +1) from @Spaces sp join dbo.[Summary] s on s.id = sp.SummaryId
update sp set sp.Space06 = charindex(' ', s.summary, sp.Space05 +1) from @Spaces sp join dbo.[Summary] s on s.id = sp.SummaryId
update sp set sp.Space07 = charindex(' ', s.summary, sp.Space06 +1) from @Spaces sp join dbo.[Summary] s on s.id = sp.SummaryId
update sp set sp.Space08 = len(s.summary)+1 from @Spaces sp join dbo.[Summary] s on s.id = sp.SummaryId
--select * from @Spaces
declare @Names as Table
(
SummaryId int not null
,Name varchar(200) not null
)
insert into @Names select s.id, SUBSTRING(s.summary, sp.Space01, sp.Space02 - sp.Space01) from @Spaces sp join dbo.[Summary] s on s.id = sp.SummaryId
insert into @Names select s.id, SUBSTRING(s.summary, sp.Space03, sp.Space04 - sp.Space03) from @Spaces sp join dbo.[Summary] s on s.id = sp.SummaryId
insert into @Names select s.id, SUBSTRING(s.summary, sp.Space05, sp.Space06 - sp.Space05) from @Spaces sp join dbo.[Summary] s on s.id = sp.SummaryId
insert into @Names select s.id, SUBSTRING(s.summary, sp.Space07, sp.Space08 - sp.Space07) from @Spaces sp join dbo.[Summary] s on s.id = sp.SummaryId
--select * from @Names
select n.SummaryId, replace(n.Name, '*','') as Name from @Names n where charindex('*',n.Name) > 0
select n.SummaryId, n.Name from @Names n where charindex('*',n.Name) = 0
Finally we can find all that spaces separating names and use it to extract names (and surnames?)
This produce the desired output
Edit
I build this solution before OP posting the USER table. Here I'm just handling bad formated data and playing with strings.
Using that USER table can do things a lot easier. Just pick each name and search it in the summary.