1
Answer

Problem with Stored Procedure

Chris Gullison

Chris Gullison

10y
823
1
Hi there, I am having great difficulty with my stored procedure. I have a form that asks the user to enter in a MedicareNum, OR LastName, OR PatientID(all three are text boxes), or can do a combination of the three. For example, if the user enters in MedicareNum 1030 it should bring up the Patient for MedicareNum 1030 (Which this does work). The only thing I can't get to work is when I type 30 for PatientID and no other data in the other two textbox searches(LastName and MedicareNum), it does not bring back the correct results, it just brings back the last row in the table which is my PatientID 60.
Any help on this would be GREATLY appreciated!!! Here is what I have so far:
 
ALTER PROCEDURE SearchByMedi
@MedicareNum nchar (10),
@LastName varchar(50),
@PatientID nchar(10)
AS
BEGIN
Select * from Patient
WHERE @MedicareNum=MedicareNum or MedicareNum='' or MedicareNum= NULL
AND (@LastName=LastName or LastName='' or LastName= NULL)
AND (@PatientID=PatientID or PatientID='' or PatientID= NULL)
END
 
 
 
Answers (1)