I am writing two queries in my sql procedure to retrieve data based on the parameter provided from the user in my asp.net application.
IF @Action = 'ID'
SELECT Name,FirstName,LastName,Employee_ID,Location FROM Salary WHERE Employee_ID=@Employee_ID
ELSE IF @Action = 'LASTNAME'
SELECT Name,FirstName,LastName,Employee_ID,Location FROM Salary WHERE LastName like '%' + @LastName + '%'
Now what I want is to combine the query into single query so that irrespective of whether ID is passed as parameter or lastname is passed i must be able to get the data.
Any help would be greatly appreciated. Thanks in Advance.