writing stored procedure to count matching words between two strings RRS feed

  • Question

  • hi all,

    I want to know that how can i write a stored procedure that takes an input param, i.e., a string and returns the count of the matching words between the input parameter and the value of a column in a table. e.g. I have a table Person with a column address. now my stored procedure matches and counts the number of words that are common between the address of the person and the input param string.  I am using Sql server 2005.

    Friday, January 19, 2007 2:35 PM

All replies

  • here you go

        @String varchar(max),
        @Word    varchar(50)
    set @String = 'Perfect OS, Perfect DatabaseB, Perfect Combination'
    set @Word = 'Perfect'

        (len(@String)- len(replace(@String,@Word,'')))/len(@Word)

    Friday, January 19, 2007 10:38 PM