Re: Need simple search string converted to full-text search string

Tech-Archive recommends: Fix windows errors by optimizing your registry



What exactly are you looking for?

Here is a proc I use - not sure if it meets with your needs or not.

usage is

declare @NumberOfRoww int
exec @NumberOfRows =SearchSQL1 'SearchPhrase'
print @numberOfRows




CREATE procedure SearchSQL1 (@stringin varchar(200), @BooleanType int= NULL)
as
-- a @boolean type of null means a phrase based search
-- a @boolean type of 1 means an OR type search
-- a @boolean type of 0 means an AND type search
declare @holdingString varchar(2000)
declare @whitespace int
declare @boolean varchar(10)
set @boolean=case when @booleantype is null then ' ' when @booleantype=1
then char(34)+' OR ' + char(34) else char(34)+' AND '+char(34) end
declare @counter int
declare @posold int
declare @posnew int
set @holdingstring='select * from authors where contains(*,'''+char(34)
select @whitespace=len(@stringin) - len(replace(@stringin,' ',''))
select @posold=0
select @posnew=Charindex(' ',@stringin)
while @whitespace >=0
begin
if @whitespace=0
begin
select @holdingString=@holdingString+substring(@stringin,@posold+1,
len(@stringin)-@posold+1)+char(34)+char(39)+')'
end
else
begin
select @holdingString = case when len(substring(@stringin,@posold+1,
@posnew-@posold-1))>0 then @holdingString+substring(@stringin,@posold+1,
@posnew-@posold-1)+@boolean else @holdingstring end
select @posold=@posnew, @posnew=Charindex(' ',@stringin, @posold+1)
end
select @whitespace=@whitespace-1
end
--print @holdingstring --uncomment for debugging
exec(@holdingstring)
return @@rowcount








--
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html

Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
.



Relevant Pages

  • Re: Front end website full-text search
    ... -- a @boolean type of null means a phrase based search ... DECLARE @whitespace INT ... Looking for a SQL Server replication book? ...
    (microsoft.public.sqlserver.fulltext)
  • Re: Searching for
    ... -- a @boolean type of null means a phrase based search ... declare @holdingString varchar ... declare @whitespace int ... Given there's a lot of items in a database> and the user is looking for a "10 inch wrench" he/she is probably typing> "wrench 10 inch". ...
    (microsoft.public.sqlserver.fulltext)
  • Re: search error
    ... -- a @boolean type of null means a phrase based search ... -- a @boolean type of 2 means an AND type search ... declare @whitespace int ...
    (microsoft.public.sqlserver.fulltext)
  • Re: Google style search
    ... -- a @boolean type of null means a phrase based search ... DECLARE @whitespace INT ...
    (microsoft.public.sqlserver.fulltext)
  • Re: Really tough ADO Stored Procedure Question. Please Help!!!
    ... @lScenarioID_CopyFrom int, ... DECLARE @ErrMSG varchar--This is the max msg size ... ROLLBACK TRANSACTION ... SELECT @lRowCountHolder = MIN ...
    (microsoft.public.sqlserver.odbc)