I have a search screen in a Visual Basic .Net App that has text boxes for:
- First Name Varchar(50)
- Last Name Varchar(50)
- Middle Name Varchar(50)
- DOB DateTime
- Home Phone Varchar(10)
- Work Phone Varchar(10)
How would I create a stored procedure in SQL Server 2000 that would allow me to be able to searh on all/some/one of the fields. If user only enters data on say first name and home phone number what would you need to do for the rest of the paramaters where data was not entered. I tried the select statement below but doesn't work properly.
Select Last_Name, First_Name, Mid_Name, DOB, Home_Phone, Work_Phone from dbo.tblClient
Where Last_Name Like '%@LastName' and
First_Name Like '%@FirstName' and
Mid_Name Like '%@MiddleName' and
DOB Like '%DOB' and
Home_Phone Like '%@HomePhone' and
Work_Phone Like '%@WorkPhone'