Create a stored procedure (or query) with all three parameters and use it like this:
@FName varchar(100)
@LName varchar(100)
@Mobno varchar(20)
SET @FName = '%' + ISNULL(LTRIM(RTRIM(@FName)), '') + CASE WHEN @FName IS NULL THEN '' ELSE '%' END
SELECT your-columns-list
FROM
your-table
WHERE
FName LIKE @Fname
AND
LName LIKE @Lname
AND
Mobno LIKE @Mobno
If you have to have exact match you can somewhat simplify
SET @FName = NULLIF(LTRIM(RTRIM(@Fname)), '')
SELECT your-column-list
FROM
your-table
WHERE
(FName = @Fname OR @Fname IS NULL)
AND
(LName = @LNAme OR @LName IS NULL)
AND
(Mobno = @Mobno OR @Mobno IS NULL)
Finally, you could just do dynamic SQL, using only the variable you have in WHERE clause and calling
sp_execute[
^] to get the result.
If this helps please take time to accept the solution. Thank you.