Reputation: 29
I want the flimname 'gladiator' not the other film name in the output
alter proc spfilmcriteria(@Minlength as int,@maxlength as int,@title as varchar)
as
begin
select filmname,filmreleasedate,filmruntimeminutes
from tblFilm
where filmruntimeminutes > @Minlength and filmruntimeminutes< @maxlength and FilmName like '%' + @title + '%'
order by filmruntimeminutes asc
end
exec spfilmcriteria 150,160,'gladiator'
Output:
filmname filmreleasedate filmruntimeminutes
Gladiator 2000-05-12 00:00:00.000 155
Harry Potter and the Goblet of Fire 2005-11-18 00:00:00.000 157
American Gangster 2007-11-16 00:00:00.000 157
Upvotes: 0
Views: 38
Reputation: 29
alter proc spfilmcriteria(@Minlength as int,@maxlength as int, @title as varchar(max))
as
begin
select filmname,filmruntimeminutes
from tblFilm
where filmruntimeminutes >= @Minlength and filmruntimeminutes<= @maxlength and FilmName like '%' + @title + '%'
order by filmruntimeminutes asc
end
Upvotes: 0
Reputation: 875
@title as varchar
It should be @title as varchar(max)
or any length you storing in database
Upvotes: 1
Reputation: 35780
You have error:
alter proc spfilmcriteria(@Minlength as int,@maxlength as int,@title as varchar)
This @title as varchar
defaults as @title as varchar(1)
So actuaally you are searching not gladiator
, but g
.
Upvotes: 2