Help me in this store procedure...

  • Dear Borther,

    In this store procedure i want search the title, description and link from search_search table but it does not show the result. I did not find any mistak in the store procedure please check the store procedure then tell me where i am wrong. the store procedure is defined here..

    ALTER PROCEDURE [dbo].[Search_Web]

    -- Add the parameters for the stored procedure here

    @SearchText varchar(50)

    AS

    BEGIN

    Select Title, Description, link

    From Search_Search

    Where Title Like 'SearchText%' AND Description Like 'SearchText%' AND link Like 'SearchText%'

    Order by Clicks

    END

    Thanks in advance

    Best regards

    Waqar Hussain Laghari

  • WHERE Title LIKE SearchText + '%'

    AND [Description] LIKE SearchText+ '%'

    AND link LIKE SearchText + '%'

  • using variables

    WHERE Title LIKE @SearchText + '%'

    AND [Description] LIKE @SearchText+ '%'

    AND link LIKE @SearchText + '%'

  • Dear brother,

    I have check these both to put into my store procedure but again it is not showing me result... Here is store procedure...

    ALTER PROCEDURE [dbo].[Search_Web]

    -- Add the parameters for the stored procedure here

    @SearchText varchar(50)

    AS

    BEGIN

    Select Title, Description, link

    From Search_Search

    Where Title LIKE @SearchText + '%' AND [Description] LIKE @SearchText+ '%' AND link LIKE @SearchText + '%'

    Order by Clicks

    END

    Please check this..

    Best regards

    Waqar Hussain Laghari

  • Can you post some sample data and the expected result ? otherwise it is really just guess work from our part.

  • I have table Search_Search Which contains these fields..

    SearchID Title Description Link Clicks

    1 Sindh This is Pakistan State http://www.sindh.com 10

    2 Karachi this is pakistan city http://www.karachi.com 20

    I want search from this if User provide me like Pakistan.. then Store Procedure will check the Pakistan word from title, description and link then it will show result like this....

    Title Description link

    Karachi this is pakistan city http://www.karachi.com

    Sindh this is pakistan State http://www.sindh.com

    ok Dear... If you have any question then ask me..

    I need this output

    Best regards

    Waqar Hussain Laghari

  • Okay I think part of the problem is that you are using AND which means that all the columns would have to contain 'Pakistan' where you may want to use OR, also if you want to search any part of the column and not just the leading edge then you need to use a leading '%' as well try,

    WHERE Title LIKE '%' + @SearchText + '%'

    OR [Description] LIKE '%' + @SearchText+ '%'

    OR link LIKE '%' + @SearchText + '%'

  • Thank you very much..

    Best regards

    Waqar Hussain Laghari

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply