all groups > inetserver asp db > july 2005 >
You're in the

inetserver asp db

group:

@parameter for Like stored proc in sql server?


@parameter for Like stored proc in sql server? jason NO[at]SPAM catamaranco.com
7/22/2005 2:26:27 PM
inetserver asp db:
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

Re: @parameter for Like stored proc in sql server? Ray Costanzo [MVP]
7/22/2005 4:00:21 PM
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

[quoted text, click to view]

AddThis Social Bookmark Button