I am trying to create a query that will return a persons name from a table.
The table contains a field called full_name.
I have created a full text index on the table on that field.
I have the following query
ALTER procedure [dbo].[spGetContactFromContactName]
@contactname VARCHAR(200)
AS
DECLARE @searchstr VARCHAR(200)
set @searchstr = '"'+REPLACE(@contactname,',','*" OR ''')+'*"'
select * from tbl_ContactDetails
where contains(Full_Name,@searchstr)
This works, but only in certain circumstances.
If the field contains the name John James Jones the query works if you enter any of the following:
[ul]
[li]John[/li]
[li]James[/li]
[li]Jones[/li]
[li]John James[/li]
[li]James Jones[/li]
[li]John James Jones[/li]
[/ul]
but it doesn't work if you enter John Jones.
I have searched online for a solution, which is where the above query came from. Any ideas or pointers would be much appreciated.
Thanks in advance
David
The table contains a field called full_name.
I have created a full text index on the table on that field.
I have the following query
ALTER procedure [dbo].[spGetContactFromContactName]
@contactname VARCHAR(200)
AS
DECLARE @searchstr VARCHAR(200)
set @searchstr = '"'+REPLACE(@contactname,',','*" OR ''')+'*"'
select * from tbl_ContactDetails
where contains(Full_Name,@searchstr)
This works, but only in certain circumstances.
If the field contains the name John James Jones the query works if you enter any of the following:
[ul]
[li]John[/li]
[li]James[/li]
[li]Jones[/li]
[li]John James[/li]
[li]James Jones[/li]
[li]John James Jones[/li]
[/ul]
but it doesn't work if you enter John Jones.
I have searched online for a solution, which is where the above query came from. Any ideas or pointers would be much appreciated.
Thanks in advance
David