@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 '+' ...
-
@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
-
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
>
>
Similar Threads
-
By Application Development in forum ADO DAO RDO RDS
Replies: 0
Last Post: 10-19-2007, 03:09 PM
-
By Application Development in forum CSharp
Replies: 2
Last Post: 08-24-2007, 08:48 AM
-
By Application Development in forum Inetserver
Replies: 1
Last Post: 03-17-2005, 11:31 AM
-
By Application Development in forum DOTNET
Replies: 0
Last Post: 05-15-2004, 08:41 AM
-
By Application Development in forum ADO DAO RDO RDS
Replies: 0
Last Post: 07-24-2003, 06:07 PM