1
I need to make a query in a table with the following words:
"Today the day got rainy"
I need to search for any of these words. For example if you found the word "day", would have to return the record to me. I mean, any of these words you find he would have to return to me.
I also need to do a survey that returns all these searched words for example:
"rainy day today"
if the record of this table has these three words not necessarily in that order would have to bring.
I’m racking my brain on how to do this. Oh I can’t use the FUllText
because I would have to ask for authorization until pro PAPA because this feature is disabled in Production. I am using SQL SERVER 2008 R2.
Thanks for the answers I managed to advance a little bit so I did more or less creating a temporary table to play my search string and separating the words by space. but I’m still in trouble
SET NOCOUNT ON
DECLARE @ARRAY VARCHAR(8000), @DELIMITADOR VARCHAR(100), @S VARCHAR(8000)
-- VALORES PASSADOS PARA A VARIAVEL @ARRAY
SELECT @ARRAY = 'hoje o dia ficou chuvoso'
-- SETANDO O DELIMITADOR
SELECT @DELIMITADOR = ' '
IF LEN(@ARRAY) > 0 SET @ARRAY = @ARRAY + @DELIMITADOR
CREATE TABLE #ARRAY(ITEM_ARRAY VARCHAR(8000))
WHILE LEN(@ARRAY) > 0
BEGIN
SELECT @S = LTRIM(SUBSTRING(@ARRAY, 1, CHARINDEX(@DELIMITADOR, @ARRAY) - 1))
INSERT INTO #ARRAY (ITEM_ARRAY) VALUES (@S)
SELECT @ARRAY = SUBSTRING(@ARRAY, CHARINDEX(@DELIMITADOR, @ARRAY) + 1, LEN(@ARRAY))
END
-- Qualquer uma das palavras
SELECT DISTINCT * FROM TABELA_A a JOIN #ARRAY ON CAMPO1 like '%' + ITEM_ARRAY + '%';
DROP TABLE #ARRAY
SET NOCOUNT OFF
In this Example it returns any of the words that are in my temporary table So far OK. But he confuses the word (day by day) this in function of the use of the Like. However, I do not know how to replace it. Moreover I could not return ONLY the records that contain all the words that are in the temporary table.
There are two things. First: Return any of the words that are in the temporary table Second: Return all words that are in the temporary table
Basically I’m taking TABLE A (TEMPORARIA) and comparing with Table B and returning the records of Table B according to the criteria I mentioned
I understood that these words 'today', 'day', 'rainy' that you used as an example may be contained in the description of the item. And that the description may even contain more than one word. This is certain?
– Reginaldo Rigo
@Fernandol: You can add table and Trigger in the development database?
– José Diz