Chris Gullison

Chris Gullison

  • NA
  • 8
  • 3.4k

Problem with Stored Procedure

Mar 31 2014 2:10 PM
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)