September 22, 2009 at 8:48 am
this is my stored procedure:
ALTER PROCEDURE [dbo].[sp_NameSearch]
-- Add the parameters for the stored procedure here
@first varchar(max),
@Race varchar(50)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT ProfileID, FullName, Race, Born, Hometown, State, Country FROM Indi WHERE FirstName LIKE '%' + @first AND Race=@race ORDER BY Born ASC
END
However, the result set is 0 even though I have the data in the database tables. Does anyone know how to write a working LIKE clause with a parameter in a stored procedure? Any help will be appreciated.
September 22, 2009 at 8:56 am
Mark-459099 (9/22/2009)
this is my stored procedure:ALTER PROCEDURE [dbo].[sp_NameSearch]
-- Add the parameters for the stored procedure here
@first varchar(max),
@Race varchar(50)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT ProfileID, FullName, Race, Born, Hometown, State, Country FROM Indi WHERE FirstName LIKE '%' + @first AND Race=@race ORDER BY Born ASC
END
However, the result set is 0 even though I have the data in the database tables. Does anyone know how to write a working LIKE clause with a parameter in a stored procedure? Any help will be appreciated.
well you could change it to
SELECT ProfileID, FullName, Race, Born, Hometown, State, Country FROM Indi WHERE FirstName LIKE '%' + @first + '%' AND Race=@race ORDER BY Born ASC
--------------------------------------------------------------------------------------
[highlight]Recommended Articles on How to help us help you and[/highlight]
[highlight]solve commonly asked questions[/highlight]
Forum Etiquette: How to post data/code on a forum to get the best help by Jeff Moden[/url]
Managing Transaction Logs by Gail Shaw[/url]
How to post Performance problems by Gail Shaw[/url]
Help, my database is corrupt. Now what? by Gail Shaw[/url]
September 22, 2009 at 3:23 pm
Can you list a couple of rows of data that you think it should return?
Also, what parameters are you passing to the stored proc?
--------------------------
I long for a job where my databases dont have any pesky users accessing them 🙂
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply