@parameter for Like stored proc in sql server? - Inetserver

This is a discussion on @parameter for Like stored proc in sql server? - Inetserver ; Could someone tell me if this parameter stored query is correct? Its not throwing up errors BUT also not returning any records...unsure if concentation is somehow needed to tie it all together? Are the apostrophe's needed...do i perhaps need '+' ...

+ Reply to Thread
Results 1 to 2 of 2

@parameter for Like stored proc in sql server?

  1. Default @parameter for Like stored proc in sql server?

    Could someone tell me if this parameter stored query is correct? Its not
    throwing up errors BUT also not returning any records...unsure if
    concentation is somehow needed to tie it all together?

    Are the apostrophe's needed...do i perhaps need '+' symbols?


    CREATE Procedure spr_GetStoryTitle
    @StoryTitle VarChar(100)
    As
    set nocount on
    SELECT *
    FROM Story
    WHERE (StoryTitle LIKE '% @StoryTitle%')
    return
    GO

    Thanks in advance
    Jason



  2. Default Re: @parameter for Like stored proc in sql server?

    You have your parameter in ', so it'll be treated as the literal string,
    "@StoryTitle."

    Do:

    CREATE Procedure spr_GetStoryTitle
    @StoryTitle VarChar(100)
    As
    set nocount on
    SELECT *
    FROM Story
    WHERE (StoryTitle LIKE '% ' + @StoryTitle + '%')
    return
    GO

    I'm assuming you intended to have the space preceding @StoryTitle.

    Ray at work

    <jason@catamaranco.com> wrote in message
    news:uV9XjrujFHA.320@TK2MSFTNGP09.phx.gbl...
    > Could someone tell me if this parameter stored query is correct? Its not
    > throwing up errors BUT also not returning any records...unsure if
    > concentation is somehow needed to tie it all together?
    >
    > Are the apostrophe's needed...do i perhaps need '+' symbols?
    >
    >
    > CREATE Procedure spr_GetStoryTitle
    > @StoryTitle VarChar(100)
    > As
    > set nocount on
    > SELECT *
    > FROM Story
    > WHERE (StoryTitle LIKE '% @StoryTitle%')
    > return
    > GO
    >
    > Thanks in advance
    > Jason
    >
    >




+ Reply to Thread

Similar Threads

  1. Replies: 0
    Last Post: 10-19-2007, 03:09 PM
  2. Argument problem with an XSD stored proc with output parameter
    By Application Development in forum CSharp
    Replies: 2
    Last Post: 08-24-2007, 08:48 AM
  3. stored proc from classic asp and ado parameter issue
    By Application Development in forum Inetserver
    Replies: 1
    Last Post: 03-17-2005, 11:31 AM
  4. Replies: 0
    Last Post: 05-15-2004, 08:41 AM
  5. how to get output parameter from stored proc call
    By Application Development in forum ADO DAO RDO RDS
    Replies: 0
    Last Post: 07-24-2003, 06:07 PM