@parameter for Like stored proc in sql server?
am 22.07.2005 20:26:27 von jason
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?
am 22.07.2005 22:00:21 von unknown
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
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
>
>