April 28, 2003 at 9:19 am
How can i CREATE PROCEDURE thet can split words like this
-------------------
@SearchField =split(MyString," ")
SELECT *
FROM OPENQUERY(NTindex, 'SELECT DocTitle,create,path,filename, rank,VPath,Contents,characterization
FROM SCOPE('' "C:\" '')')
WHERE FREETEXT('+ @SearchField + ' AND)
so thet "@SearchField + ' AND" can split
And put AFTER EVRY WORD "AND"
do this !!!!!!!!!!
---------
"WHERE FREETEXT('word_1 'AND' word_2 And 'WORD 3'.....)
and LOOP it
-----------
thnks ilan
April 29, 2003 at 6:34 pm
Hi Ilan,
I think the code below can help you. Please note that the input you give must end with a space.
DECLARE
@SearchField VARCHAR(100),
@temp VARCHAR(10),
@Output VARCHAR(100),
@counter INT
BEGIN
SELECT @SearchField 'select1 select2 select3'
Print @SearchField
SELECT @Counter = CHARINDEX(@SearchField,' ')
SELECT @Output = ''
WHILE(@Counter>0)
BEGIN
SELECT @temp = SUBSTRING(@SearchField,1,@Counter)
SELECT @Output = @Output + @temp + ' AND '
SELECT @SearchField =SUBSTRING(@SearchField, @Counter+1)
SELECT @Counter = CHARINDEX(@SearchField,' ')
END
SELECT@Output = SUBSTRING(@Output, 1, LEN(@Output)-4)
PRINT @Output
END
*** I didnt execute the code since i dont have SQLServer in my machine rite now. I guess the code is bug free.
April 30, 2003 at 4:15 pm
thnks but i have an error
---------------
Server: Msg 174, Level 15, State 1, Line 16
The substring function requires 3 arguments.
thnks
ilan
May 2, 2003 at 9:53 am
Try this
DECLARE
@SearchField VARCHAR(100),
@a varchar(5),
@Temp VARCHAR(100),
@Output VARCHAR(100),
@counter INT
SET @SearchField = 'select1 select2 select3'
SET @Temp = @SearchField
Print @Temp
SET @Output = ''
SET @a = ''
WHILE (@Temp <> '')
BEGIN
SET @Counter = CHARINDEX(' ',@Temp+' ')
SET @Output = @Output + @a + LEFT(@Temp,@Counter-1)
SET @Temp = LTRIM(SUBSTRING(@Temp+' ',@Counter,(LEN(@Temp)+1)-@Counter))
SET @a = ' AND '
END
PRINT @Output
Far away is close at hand in the images of elsewhere.
Anon.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply